The following code executes perfectly:
@override
State<NewTransaction> createState() => _NewTransactionState();
This code, however, does not. Error is: The body might complete normally, causing 'null' to be returned...
@override
State<NewTransaction> createState() {
_NewTransactionState();
}
Why? Isn't this just two alternative ways of writing the same thing?
(Latest Android Studio if that is important).
CodePudding user response:
The second function is missing a return
statement.
@override
State<NewTransaction> createState() {
return _NewTransactionState();
}
CodePudding user response:
The second one must return the state like this:
@override
State<NewTransaction> createState() {
return _NewTransactionState();
}