Home > Blockchain >  flutter passing a function with parameters
flutter passing a function with parameters

Time:10-09

I've an issue with a function that I pass as parameter. I dont understand why I've this error 'the parameter '' can't have a 'null' because of its type'

I made a function that Push a new screen in my statefull class (changeAuthScreen). And I call it and my widget function ButtonAuth (onPressed). the class where there's the error

the function that I use for call the class

where this function is called

CodePudding user response:

The issue raise because of null-safety aware. While the bool is final, you need to make it required like or provide default value .

const AuthScreen({super.key, required this.newUser});

or

const AuthScreen({super.key, this.newUser = false});

Find more about understanding-null-safety

CodePudding user response:

In line 17, you have to add the required keyword:

const AuthScreen({Key? key, required this.newUser}) : super(key);

This will fix the issue.

  • Related