0
votes

shared_preferences: ^0.5.12+4

Error log: MissingException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

flutter sdk details:

[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.14.6 18G7016 darwin-x64, locale en-US) • Flutter version 1.22.5 at /Users/taleb/Developer/flutter • Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800 • Engine revision ae90085a84 • Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/taleb/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = /Users/taleb/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch • CocoaPods version 1.8.3

[✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin installed • Dart plugin version 201.9317 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 45.1.2 • Dart plugin version 193.7547

[✓] Connected device (1 available) • SM A107F (mobile) • R9AM905ZREJ • android-arm • Android 10 (API 29)

! Doctor found issues in 1 category.

1
shared preferences is one of those package the updates frequently and they normally haven't backward compatibility. I choose to use a fix version. Right now I am using 0.5.7+3 which is working without issue for me in any mode. Check this solution it may help you.mahdi shahbazi
@mahdishahbazi Thanks for your help , i also test release mode with 0.5.7+3 version, but i still have problem with prefrs :(Taleb
What error are you getting?Andrej
@mahdishahbazi In the release mode i can't see the log , i just tested with removing prefrs and i see everything ok and when i added prefrs i got problem!!! for example in the "splashPage" of the app i'm checking user is logged in or not with prefrs and i still remain in the "splashPage" and nothing happend...Taleb
@Taleb try to use FlutterError.onError or ErrorWidget.builder to show your error on a screen or log into a log file.mahdi shahbazi

1 Answers

2
votes

If you're using shared_preferences 0.2.4 and above, use setMockInitialValues:

SharedPreferences.setMockInitialValues({}); // set initial values here if desired

For earlier versions you can do it manually:

const MethodChannel('plugins.flutter.io/shared_preferences')
  .setMockMethodCallHandler((MethodCall methodCall) async {
    if (methodCall.method == 'getAll') {
      return <String, dynamic>{}; // set initial values here if desired
    }
    return null;
  });