16

I am using awesome_notifications library, and to prevent, for example, MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) it uses in AppDelegate:

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")!)
      }

But I still have error with my custom channel: Unhandled Exception: MissingPluginException(No implementation found for method flutterToWatch on channel it.example.watch) And I don't know how to register it in the background like awesome_notifications do it.

My channel:

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 = call.arguments as? [String: Any], let method = methodData["method"], let data = methodData["data"] else {
                                            result(false)
                                            return
                                        }
                    
                    let watchData: [String: Any] = ["method": method, "data": data]
                    
                    // Pass the receiving message to Apple Watch
                    watchSession.sendMessage(watchData, replyHandler: nil, errorHandler: nil)
                    result(true)
                default:
                    result(FlutterMethodNotImplemented)
                }
            })
        }
    }
Arsen Tatraev
  • 470
  • 1
  • 4
  • 16

11 Answers11

31

Just close the app running on your Editor, and start your app to run again (dont hot restart / hot reload), stop your app and start it again!

iamJohnvesly
  • 391
  • 3
  • 5
10

I had this bug recently when changing few packages.

I just clear Flutter with flutter clean, delete pubspec.lock, and Invalidate and Restard Android Studio. A last flutter pub get to restore packages and everything worked good.

Turvy
  • 882
  • 1
  • 8
  • 23
3

I quote from https://github.com/flutter/flutter/issues/98473 which solved the problem for me:

To summarize the actual solution: at the start of the entry point for any isolate that needs to use plugins (where you are presumably already calling WidgetsFlutterBinding.ensureInitialized()):

For Flutter 2.11+ (currently master), call DartPluginRegistrant.ensureInitialized(), which will run the Dart plugin registration for all plugins that need it. For older versions of Flutter, manually call the registerWith of any plugin implementations you use that have Dart registration. For shared_preferences, see above for details.

Since the plan going forward is to require DartPluginRegistrant.ensureInitialized() in isolates, closing as fixed.

Community
  • 1
  • 1
Ole
  • 480
  • 4
  • 11
2

I've faces same issue here and error was in AppDelegate.swift By putting in this line of code

GeneratedPluginRegistrant.register(with: self)

I solved this problem

Vepa Sabyrow
  • 121
  • 1
  • 3
  • 10
2

I also faced the error-

Error: MissingPluginException(No implementation found for method initialize on channel plugin.csdcorp.com/speech_to_text)

This page- Github issue link helped me. I changed my plugin version in pubspec.yaml file and it worked for me.

Edited code

Or

you can use the command in terminal-

flutter pub outdated
flutter pub upgrade --major-versions
1

i fixed that by run my flutter app again.

1

close the app and then just run.

flutter clean;
flutter pub get;
flutter run;

You'll get to go.

Adeel Nazim
  • 640
  • 6
  • 17
0

Just stop you app and restart it again will solve the problem in most of the cases.

This happens because some native dependency requires an update and that only happens when you restart the application.

Shrey Jain
  • 73
  • 1
  • 5
0

if you are using await window_manager package, make sure you wrarp ensureInitialized() method inside a function that has approved it is a wondows platform, otheriwise if you call that method before checking is a windows platform, your app will crash and show black screen. do it like in the code below

if (Platform.isWindows) {
    await windowManager.ensureInitialized();
    WindowManager.instance
        .setMinimumSize(Size(Get.width / 1.2, Get.height / 1.2));
  }

REMEMBER TO THANK ME IF IT HELPS YOU!

MUHINDO
  • 788
  • 6
  • 10
-1

If your reason for encountering this problem was because you downloaded google_font into you pub.yaml. Please restart the project from afresh, while your internet is on

Nuel
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 04 '22 at 12:47
-3

this can be solved by putting some changes in build.gradle under build types

proguardFiles(
    getDefaultProguardFile("proguard-android-optimize.txt"),
    "proguard-rules.pro"
)A

reference: https://developer.android.com/studio/build/shrink-code#kts