File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -51,19 +51,24 @@ class Application extends StatefulWidget {
5151class _Application extends State<Application> {
5252 String _token;
5353
54- @override
55- void initState() async {
56- super.initState();
54+ Future<void> setupToken() async {
5755 // Get the token each time the application loads
58- String token = await FirebaseMessaging.instance.getToken();
56+ String? token = await FirebaseMessaging.instance.getToken();
5957
6058 // Save the initial token to the database
61- await saveTokenToDatabase(token);
59+ await saveTokenToDatabase(token! );
6260
6361 // Any time the token refreshes, store this in the database too.
6462 FirebaseMessaging.instance.onTokenRefresh.listen(saveTokenToDatabase);
6563 }
6664
65+ @override
66+ void initState() {
67+ super.initState();
68+
69+ setupToken();
70+ }
71+
6772 @override
6873 Widget build(BuildContext context) {
6974 return Text("...");
You can’t perform that action at this time.
0 commit comments