Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in debug console on anonymous logout #4

Open
cklanac opened this issue Aug 16, 2020 · 1 comment
Open

error in debug console on anonymous logout #4

cklanac opened this issue Aug 16, 2020 · 1 comment

Comments

@cklanac
Copy link

cklanac commented Aug 16, 2020

I received the following error in the debug console when clicking "logout". Note: the error might only appear using the latest packages.

flutter: 'package:provider/src/provider.dart': Failed assertion: line 202 pos 7: 'context.owner.debugBuilding ||
          listen == false ||
          debugIsInInheritedProviderUpdate': Tried to listen to a value exposed with provider, from outside of the widget tree.
This is likely caused by an event handler (like a button's onPressed) that called
Provider.of without passing `listen: false`.
To fix, write:
Provider.of<AuthBase>(context, listen: false);
It is unsupported because may pointlessly rebuild the widget associated to the
event handler, when the widget tree doesn't care about the value.
The context used was: AccountPage(dependencies: [_LocalizationsScope-[GlobalKey#7b2b3], _InheritedProviderScope<User>, _InheritedCupertinoTheme])
@cklanac
Copy link
Author

cklanac commented Aug 16, 2020

Adding listen:false to the Provider in the _signOut method resolves the issue. See PR #3

class AccountPage extends StatelessWidget {
  Future<void> _signOut(BuildContext context) async {
    try {
      final auth = Provider.of<AuthBase>(context, listen: false);
      await auth.signOut();
    } catch (e) {
      print(e.toString());
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant