I want to clear shared preferences when I send a FCM message and app is in background. Inside myBackgroundMessageHandler
method I am calling a method to clear them.
static Future<dynamic> myBackgroundMessageHandler(
Map<String, dynamic> message) {
clearPreferences();
}
static void clearPreferences() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.clear();
}
I am getting the following error:
Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)