Vetrivelu Murugesan
Vetrivelu Murugesan

Reputation: 33

FlutterFire Messaging : MissingPluginException error thrown for Shared Preferences

I'm using firebase and shared_preference in my flutter project, where I need to store a incoming message to the shared preferences. Whenever a message is received, I am getting the below exception

I/flutter (29300): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (29300): MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

I know that _firebaseMessagingBackgroundHandler will spawn a new isolate, but does that make other plugins unaccessible?? This is my handler

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  final prefs = await SharedPreferences.getInstance();
  await prefs.reload();
  await prefs.setStringList(
      DateTime.now().toIso8601String().substring(0, 19) + ".000000", [message.notification!.body.toString(), message.notification!.title.toString()]);
}

I have also confirmed that shared preferences present in generated_plugin_registrant.dart. I have used FlutterFire CLI for integerating firebase with my app.

Upvotes: 3

Views: 406

Answers (1)

Barzi Yassin
Barzi Yassin

Reputation: 206

MissingPluginException error mostly solved by terminating then re-running the project, however in some cases it may not.

Upvotes: 0

Related Questions