我正在使用Awesome_notifications库,并防止它在 AppDelegate 中使用,例如MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现) :
SwiftAwesomeNotificationsPlugin.setPluginRegistrantCallback { registry in
SwiftAwesomeNotificationsPlugin.register(
with: registry.registrar(forPlugin: "io.flutter.plugins.awesomenotifications.AwesomeNotificationsPlugin")!)
FLTSharedPreferencesPlugin.register(
with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")!)
}
Run Code Online (Sandbox Code Playgroud)
但我的自定义通道仍然有错误: 未处理的异常:MissingPluginException(在通道 it.example.watch 上找不到方法 flutterToWatch 的实现) 而且我不知道如何像 Awesome_notifications 那样在后台注册它。
我的频道:
private func initFlutterChannel() {
if let controller = window?.rootViewController as? FlutterViewController {
let channel = FlutterMethodChannel(
name: "it.example.watch",
binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler({ [weak self] (
call: FlutterMethodCall,
result: @escaping FlutterResult) -> Void in
switch call.method {
case "flutterToWatch":
guard let watchSession = self?.session, watchSession.isPaired, watchSession.isReachable, let methodData …Run Code Online (Sandbox Code Playgroud) 我收到 MissingPlugin 错误。我发现了很多关于该错误的帖子。但我的情况有点不同。\n首先,我的项目在模拟器中运行良好,只有当我在物理 Android 上运行我的发布应用程序时才会出现该错误。\n其次,此错误不仅仅与一个包相关。我首先收到类似\nMissingPluginException(在通道plugins.flutter.io/shared_preferences上找不到方法getAll的实现)\n的错误\n在我放置代码后,我发现只能使用shared_preferences来处理问题。然后我得到了类似\nMissingPluginException(在通道plugins.flutter.io/package_info上找不到方法getAll的实现)\n的错误\n显然,该错误不仅仅链接到像shared_preferences这样的一个包。
\n任何想法?我该如何解决这个问题\xef\xbc\x9f
\n我正在尝试测试一个函数,该函数进行 api 调用并将该数据保存到共享首选项中。我正在嘲笑我的 api 调用,但是在该函数中,当我尝试获取共享首选项的实例时,出现此错误:
MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现)
这是我的测试用例代码。
main() {
// setup
group("Login", () {
setUp(() {
flutterTest.TestWidgetsFlutterBinding.ensureInitialized();
});
test("Valid Creds Login", () async {
final validRes = ExpectedResponses.login();
final client = MockClient((request) async {
final res = json.encode(validRes);
return Response(res, 200);
});
ApiController.init(client);
final user = await ApiController.login(
email: "abc@gmail.com", password: "12345678");
expectAsync0(() {
expect(user.id, "1763");
});
}, skip: false);
});
}
Run Code Online (Sandbox Code Playgroud) 我的Flutter应用程序使用Flutter SharedPreferences插件,并通过platform.invokeMethod将值发送到iOS端。如果我启动应用程序,则出现此错误:
[VERBOSE-2:dart_error.cc(16)] 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:278:7)
<asynchronous suspension>
#1 SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:25:27)
<asynchronous suspension>
#2 main (file:///Users/Developer/workspace/flutter-app/q_flutter2/lib/main.dart:25:53)
<asynchronous suspension>
#3 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
Run Code Online (Sandbox Code Playgroud)
如果我注释了将值发送到iOS端的函数,则不会显示错误,并且SharedPreferences可以正常工作。
有人可以帮我吗?