Exception has occurred. _CastError (type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'String' in type cast)
364
In print('Token: ' + val);
the val here is a Map<dynamic, dynamic>
. You need to access the key of they value you need.
You can type print('Token: ' + $val);
to see how it looks like.
Author by
Brightcode
Updated on December 28, 2022Comments
-
Brightcode over 1 year
Am trying to get an FCM Token using
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; const String firebaseCloudvapidKey = "MY_PUBLIC_KEY_IS_HERE"; _firebaseMessaging.getToken(vapidKey: firebaseCloudvapidKey).then((val) async { print('Token: ' + val); });
This is the error i get whenever i run this
Am using genymotion emulator and i don't know where the error is coming from please help me out and if you need more explanation tell me i will add to it