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

Context can't be defined in a singleton, so can't handle notifications at all! #1

Open
yoniker opened this issue Dec 14, 2021 · 0 comments

Comments

@yoniker
Copy link

yoniker commented Dec 14, 2021

I'm coming from your tutorial here:

https://blog.logrocket.com/implementing-local-notifications-in-flutter/

The problem in your tutorial is that in the singleton there's no context,so it's impossible to use Navigator to handle notifications.

To see the problem clearly just replace the current selectNotification which does nothing, to the code that was mentioned in the tutorial:

Future selectNotification(String? payload) async {
  await Navigator.push(
    context,
    MaterialPageRoute<void>(builder: (context) => SecondScreen(payload)),
  );
}

to get the error that context was not defined.

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