Describe the bug
I've enable Firebase Crashlytics in my android app which detected a failed null check. My guess is that, await _submitController.reverse(); is called in an async gap and when it is called, the widget is not mounted anymore.
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value
at AnimationController.stop(animation_controller.dart:778)
at AnimationController._animateToInternal(animation_controller.dart:598)
at AnimationController.reverse(animation_controller.dart:495)
at _LoginCardState._submit(login_card.dart:218)
In my opinion the fix would be to check whether the context is still mounted before calling _submitController.reverse(), like the following.
diff --git a/lib/src/widgets/cards/login_card.dart b/lib/src/widgets/cards/login_card.dart
index 8db3355..e3b1ef2 100644
--- a/lib/src/widgets/cards/login_card.dart
+++ b/lib/src/widgets/cards/login_card.dart
@@ -215,7 +215,9 @@ class _LoginCardState extends State<_LoginCard> with TickerProviderStateMixin {
}
});
- await _submitController.reverse();
+ if (mounted) {
+ await _submitController.reverse();
+ }
if (!DartHelper.isNullOrEmpty(error)) {
showErrorToast(context, messages.flushbarTitleError, error!);
To Reproduce
Steps to reproduce the behavior:
Go to the login page
Fill the email and username with invalid credentials
Click on login
Push the back button of the phone to leave the screen before the result comes back
Check the error log for errors
You may have to repeat it a few times as pushing the back button have to take place in exactly the right moment, however I could reproduce it several times with the described method.
Expected behavior
Do not crash on the null check.
Information (please complete the following information):
Describe the bug I've enable Firebase Crashlytics in my android app which detected a failed null check. My guess is that,
await _submitController.reverse();
is called in an async gap and when it is called, the widget is not mounted anymore.In my opinion the fix would be to check whether the context is still mounted before calling _submitController.reverse(), like the following.
To Reproduce Steps to reproduce the behavior:
You may have to repeat it a few times as pushing the back button have to take place in exactly the right moment, however I could reproduce it several times with the described method.
Expected behavior Do not crash on the null check.
Information (please complete the following information):