Flutter - how to get current context?

前端 未结 3 376
刺人心
刺人心 2021-01-18 20:48

I am using Firebase cloud messaging for notifications, and i want to show a dialog or snackbar once i receive a notification when i am inside the application, my problem is

3条回答
  •  -上瘾入骨i
    2021-01-18 21:22

    I had the exact same issue, but I found a brilliant thread on GitHub. Basically, you can create a navigatorKey and pass that in to MaterialApp, and then use that navigatorKey to change route.

    See how in this thread: https://github.com/brianegan/flutter_redux/issues/5#issuecomment-361215074

提交回复
热议问题