0

I'm not sure if this comes from my lack of fundamentals of flutter, but I have this code that isn't working.

If I set the success to true, I don't get the error, if I remove the bool assignment and the conditional it works, however together it doesn't work.

Is the error just wrong, because it does look like it could be an NPE, but it doesn't say what's null? I feel like the issue comes from my createuser function and not from the page routing.

I did look at this Looking up a deactivated widget's ancestor is unsafe however I don't think it solves my issue

try {
      bool success = await auth.createUser(firstName: firstName, lastName: lastName,
        email: email, password: password);

      if (success) {
        Navigator.pushReplacement(context,
          CupertinoPageRoute(
            builder: (_) => NextPage(),
          ),
        );
      }
    } catch (e) {
      loading = false;
      notifyListeners();
      print(e);
      showInSnackBar(
          '${auth.handleFirebaseAuthError(e.toString())}', context);
    }

Exception

I/flutter ( 6231): Null check operator used on a null value
E/flutter ( 6231): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 
Looking up a deactivated widget's ancestor is unsafe.
E/flutter ( 6231): At this point the state of the widget's element tree is no longer stable.
E/flutter ( 6231): To safely refer to a widget's ancestor in its dispose() method, save a 
reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's 
didChangeDependencies() method.
Spider
  • 391
  • 4
  • 17

0 Answers0