Thee error message is pretty explicit: the function returns a nullable value -
- and you are trying to store it in a non-nullable type -
; the types are not the same.
The simplest solutions are to change the type of
, or change the return value of
There are other ways, but they are more complicated: https://stackoverflow.com/questions/67246851/in-dart-given-the-nullable-type-t-how-do-i-get-the-non-nullable-one-t