Repository: flutter
Issue: Allow registering individual plugin implementations by name from Dart
Labels: c: new feature,tool,engine,P3,a: plugins,team-engine,triaged-engine

Hello!

Im trying to create a background Flutter Engine to execute dart code while the app is terminated. This is necessary to receive user's notification action without bring the app to foreground, for my plugin called [Awesome Notifications](https://pub.dev/packages/awesome_notifications).

But im struggling to discover how to register the plugins on iOS, to allow then to be used inside the new Flutter Engine instance.

How should I register all plugins to be used inside my background Flutter Engine?
(or even better, how to register manually only the necessary plugins on dart code)

## Steps to Reproduce

This is my simplified swift code (the current real implementation can be found [here](https://github.com/rafaelsetragni/awesome_notifications/blob/add0ff600482df2742f1f957efcc14372abb4470/ios/Classes/lib/DartBackgroundExecutor.swift#L100)):
```Swift
DispatchQueue.main.async {
    
    self.backgroundEngine = FlutterEngine(
        name: "AwesomeNotificationsBgEngine",
        project: nil,
        allowHeadlessExecution: true
    )
    
    if self.backgroundEngine == nil {
        Log.d(self.TAG, "Flutter background engine is not available.")
        self.closeBackgroundIsolate()
    }
    else {
        
        self.backgroundEngine!.run(
            withEntrypoint: dartCallbackInfo.callbackName,
            libraryURI: dartCallbackInfo.callbackLibraryPath) 
                
        self.flutterPluginRegistrantCallback?(
            self.backgroundEngine!)
        
        self.initializeReverseMethodChannel(
            backgroundEngine: self.backgroundEngine!)
    }
}
```

...and on dart code:

```Dart
static Future<void> onActionReceivedMethod(ReceivedAction receivedAction) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.setString('stringValue', "abc");
}
```

...it works well on Android, but on iOS im getting this error:
`MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)`

But that's not shared_preferences fault, it could be any other plugin in the error, mine included. It's because I'm not registering the plugins on Flutter Engine startup.

## Logs

<details>

<summary>Logs</summary>

```
2022-03-09 21:11:13.101240-0300 Runner[57894:1577666] Metal API Validation Enabled
2022-03-09 21:11:13.293137-0300 Runner[57894:1578362] flutter: Observatory listening on http://127.0.0.1:50265/X7X9IsfkknQ=/
2022-03-09 21:11:13.305895-0300 Runner[57894:1577666] LifeCycleManager subscribe(listener:):77 LiceCycleManager listener successfully attached to iOS
2022-03-09 21:11:13.309764-0300 Runner[57894:1577666] LifeCycleManager currentLifeCycle:138 App is now AppKilled
2022-03-09 21:11:13.325634-0300 Runner[57894:1577666] AwesomeNotificationsPlugin AttachAwesomeNotificationsPlugin(usingRegistrar:throughFlutterChannel:):67 Awesome Notifications plugin attached to iOS 1856.0
2022-03-09 21:11:13.325706-0300 Runner[57894:1577666] AwesomeNotificationsPlugin AttachAwesomeNotificationsPlugin(usingRegistrar:throughFlutterChannel:):68 Awesome Notifications - App Group : group.AwesomeNotifications.me.carda.awesomeNotificationsExample
Engine creation error: Error Domain=com.apple.CoreHaptics Code=-4809 "(null)"
2022-03-09 21:11:13.394346-0300 Runner[57894:1577666] AwesomeNotifications didFinishLaunch(_:):489 Awesome Notifications attached for iOS
2022-03-09 21:11:13.452871-0300 Runner[57894:1577666] LifeCycleManager currentLifeCycle:138 App is now Foreground
2022-03-09 21:11:13.781845-0300 Runner[57894:1577666] AwesomeNotifications initialize(defaultIconPath:channels:backgroundHandle:debug:):395 Awesome Notifications initialized
2022-03-09 21:11:13.781970-0300 Runner[57894:1577666] AwesomeNotificationsPlugin channelMethodInitialize(call:result:):845 Awesome Notifications service initialized
2022-03-09 21:11:13.783210-0300 Runner[57894:1577666] AwesomeEventsReceiver subscribeOnNotificationEvents(listener:):36 <awesome_notifications.AwesomeNotifications: 0x60000185adf0> subscribed to receive notification events
2022-03-09 21:11:13.783372-0300 Runner[57894:1577666] AwesomeEventsReceiver subscribeOnActionEvents(listener:):75 <awesome_notifications.AwesomeNotifications: 0x60000185adf0> subscribed to receive action events
2022-03-09 21:11:13.783430-0300 Runner[57894:1577666] AwesomeNotifications attachAsMainInstance(usingAwesomeEventListener:):123 Awesome notifications 105553141804528 attached to app instance
Notification category identifier: DEFAULT,SNOOZE
2022-03-09 21:17:33.718065-0300 Runner[57894:1577666] BackgroundService enqueue(SilentBackgroundAction:withCompletionHandler:):33 A new Dart background service has started
2022-03-09 21:17:43.178534-0300 Runner[57894:1585586] flutter: Got an unknown Silent Action callback error: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
2022-03-09 21:17:43.178895-0300 Runner[57894:1585586] flutter:
2022-03-09 21:17:43.179224-0300 Runner[57894:1585586] flutter: Awesome Notifications FCM: An error occurred in your background messaging handler:
2022-03-09 21:17:43.179377-0300 Runner[57894:1585586] flutter: Instance of 'AwesomeNotificationsException'
2022-03-09 21:17:43.182534-0300 Runner[57894:1577666] DartBackgroundExecutor finishDartBackgroundExecution():182 All silent data fetched.
```

```
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-arm, locale en-BR)
    • Flutter version 2.10.2 at /Users/carda/Desenvolvimento/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 097d3313d8 (3 weeks ago), 2022-02-18 19:33:08 -0600
    • Engine revision a83ed0e5e3
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/carda/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • 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
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.65.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 6C5C5F32-D01E-4108-B539-A61B00D5DF32 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 99.0.4844.51

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>