shared preferences not working in the background in flutter

Viewed 953

i am using shared_preferences: ^2.0.7 with flutter_background_service: ^0.1.5 in flutter but when call shared preferences give me the error

"Flutter: Unhandled exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)"

When working in the forground mode, the call is done correctly, this problem occurs only about the call in the background mode.

1 Answers

usually this happens when thirdparty pulgin files are not properly included in build apk , to avoid this try :

flutter clean
flutter pub get
flutter run

this will make sure proper build with required files.

Tip : when adding a new plugin to pubspec.yaml file avoid Hot reload and Hot restart make sure to build apk from scratch so that all required files included in your build.

Related