Flutter - how to get current context?

前端 未结 3 378
刺人心
刺人心 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条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 21:17

    do the initializing inside a build method of your first widget in the tree ! which normally it called an App widget and it is StateLess StateFull widget and inside the build method you have access to the BuildContext

提交回复
热议问题