I am making an app in flutter using firebase for login and signup functionaity. I want to display the exception caused while this firebase auth as flutter toast so that the user can understand what's going wrong.
But the error.message provided by firebase is nullable string and flutter toast message needs a string as parameter so it' showing this error
The argument type 'String?' can't be assigned to the parameter type 'String'.dart(argument_type_not_assignable)
Code and error:
Can anyone help me out to display this?
try{
// code here
}
on FirebaseAuthException catch (error) {
Fluttertoast.showToast(msg: error.message, gravity: ToastGravity.TOP);
}
You can use the !
(bang) operator:
Fluttertoast.showToast(msg: error!.message!, gravity: ToastGravity.TOP);
You can read more about argument_type_not_assignable