Repository: flutter
Issue: MissingPluginException no longer works with additional ViewControllers
Labels: in triage

### Steps to reproduce

1. adding watchKit with this tutorial: https://github.com/theamorn/flutter-apple-watch/tree/main
2. adding additional SplashController with this tutorial:  https://medium.com/@turkergurel19/native-animated-splash-screen-with-lottie-in-flutter-21761532813b
3. try to work with MethodChannel

### Expected results

I try to implement watchkit to my app with this tutorial:

https://github.com/theamorn/flutter-apple-watch/tree/main

It is working perfectly. WCSession is working and invokeMethod as well.

But since I want to have an animated LaunchScreen, I have built a SplashController according to this tutorial and then change the rootViewController within the SplashController:

https://medium.com/@turkergurel19/native-animated-splash-screen-with-lottie-in-flutter-21761532813b

`appDelegate.window?.rootViewController = flutterViewController`

### Actual results

After adding the LaunchScreen, the invokeMethod function no longer works and the sending between watch and iPhone as well. I get the following error:

```
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: MissingPluginException(No implementation found for method forwardToAppleWatch on channel com.XXX.app.watchkitapp)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
<asynchronous suspension>
```

### Code sample

<details open><summary>Code sample</summary>

I have the following AppDelegate in Xcode:


```dart

import UIKit
import Flutter
import WatchConnectivity

@main
@objc class AppDelegate: FlutterAppDelegate {
    
    let flutterEngine = FlutterEngine(name: "XXX")
    
    private var session: WCSession?
    private var channel: FlutterMethodChannel?
    
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Runs the default Dart entrypoint with a default Flutter route.
         flutterEngine.run()
        
        // Watch
        initWatchConnectivity()
        initFlutterChannel()
        
        // Used to connect plugins (only if you have plugins with iOS platform code).
         GeneratedPluginRegistrant.register(with: self.flutterEngine)
        
      //  GeneratedPluginRegistrant.register(with: self)
        
        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
        }
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    private func initWatchConnectivity() {
        guard WCSession.isSupported() else { return }
        session = WCSession.default
        session?.delegate = self
        session?.activate()
    }
    
    private func initFlutterChannel() {
        DispatchQueue.main.async {
            guard let controller = self.window?.rootViewController as? FlutterViewController else { return }
            
            let channel = FlutterMethodChannel(name: "com.XXX.app.watchkitapp", binaryMessenger: controller.binaryMessenger)
            channel.setMethodCallHandler { [weak self] call, result in
                let method = call.method
                let args = call.arguments
                
                guard method == "forwardToAppleWatch" else { return }
                guard let watchSession = self?.session, watchSession.isPaired, let messageData = args as? [String: Any] else {
                    print("watch not paired")
                    return
                }
                
                guard watchSession.isReachable else {
                    print("watch not reachable")
                    return
                }
                
                watchSession.sendMessage(messageData, replyHandler: nil, errorHandler: nil)
            }
            self.channel = channel
        }
    }
    
}

extension AppDelegate: WCSessionDelegate {
    func sessionDidBecomeInactive(_ session: WCSession) { }
    func sessionDidDeactivate(_ session: WCSession) { }
    func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { }
    
    func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
        guard let methodName = message["method"] as? String else { return }
        let data: [String: Any]? = message["data"] as? [String: Any]
        channel?.invokeMethod(methodName, arguments: data)
    }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.2, on macOS 14.7.1 23H222 darwin-arm64, locale de-DE)
    • Flutter version 3.27.2 on channel stable at /Users/XXX/development/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (vor 10 Tagen), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/XXX/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/XXX/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/XXX/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (5 available)
    • iPhone (mobile)           • 00008130-000A49440230001C            • ios            • iOS 18.2 22C152
    • iPhone 15 Pro with Watch (mobile) • CF5C8BA0-032C-426B-959D-14E6BF521C7F • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)                   • macos                                • darwin-arm64   • macOS 14.7.1 23H222 darwin-arm64
    • Mac Designed for iPad (desktop)   • mac-designed-for-ipad                • darwin         • macOS 14.7.1 23H222 darwin-arm64
    • Chrome (web)                      • chrome                               • web-javascript • Google Chrome 132.0.6834.110

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>