MissingPluginException(MissingPluginException(在通道plugins.flutter.io/shared_preferences上未找到方法getAll的实现))

时间:2020-10-14 02:30:30

标签: flutter dart flutter-dependencies

pubspec.yaml(shared_preferences:)

我已经初始化了代码main.dart文件

WidgetsFlutterBinding.ensureInitialized();

并同时使用

 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;
  });

然后尝试将字符串存储在shared_preferences

final prefs = await SharedPreferences.getInstance();

我已经多次使用flutter clean命令

然后我将尝试删除shared_preferences,但无法在我的项目中完全删除

0 个答案:

没有答案