Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences #21

Closed
chenyanbin-dkhs opened this issue Oct 8, 2019 · 1 comment

Comments

@chenyanbin-dkhs
Copy link

Flutter 1.10.14-pre.12
Dart 2.6.0

errors:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
<asynchronous suspension>
#1      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
<asynchronous suspension>
#2      SharedPreferences._getSharedPreferencesMap (package:shared_preferences/shared_preferences.dart:158:25)
<asynchronous suspension>
#3      SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:25:17)
<asynchronous suspension>
#4      SpUtil._init (package:flustars/src/sp_util.dart:40:38)
<asynchronous suspension>
#5      SpUtil.getInstance.<anonymous closure> (package:flustars/src/sp_util.dart:29:27)
<asynchronous suspension>
#6      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:31:26)
<asynchronous suspension>
#7      SpUtil.getInstance (pac<…>

解决方法:

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

await SpUtil.getInstance();

//  todo more
@Sky24n
Copy link
Owner

Sky24n commented Oct 8, 2019

不需要的,都使用很久了,没有问题的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants