Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rh-id/flutter_serviceloader_plugin
Flutter plugin used to handle FlutterPlugin instances by registering service resource as list of FlutterPlugin instead of official way
https://github.com/rh-id/flutter_serviceloader_plugin
Last synced: 8 days ago
JSON representation
Flutter plugin used to handle FlutterPlugin instances by registering service resource as list of FlutterPlugin instead of official way
- Host: GitHub
- URL: https://github.com/rh-id/flutter_serviceloader_plugin
- Owner: rh-id
- License: mit
- Created: 2021-01-14T09:13:49.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-02T11:15:37.000Z (over 3 years ago)
- Last Synced: 2023-03-05T18:58:21.276Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 70.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# flutter_serviceloader_plugin
Flutter plugin used to handle FlutterPlugin instances using ServiceLoader instead of defining it in `pubspec.yaml` dependencies.
The benefit of using this plugin is that it works for plugin that execute dart function in background such as `android_alarm_manager` plugin.
In order to execute dart function in background we need to instantiate `new FlutterEngine(context)` and execute the dart function using the engine instance.
The engine instance automatically register all plugins using reflection during instantiation (calling generated class `GeneratedPluginRegistrant.registerWith`).
Since this plugin will be registered in that generated class and forward all events to the ServiceLoader FlutterPlugin classes, when dart function call platform channel within ServiceLoader FlutterPlugin it will work. If you register all the plugin in your `MainActivity` class it will not work since flutter engine didn't call/invoke `MainActivity`## Getting Started
Only for Android platform.
1. On your android project create new Java resource folder (if you haven't create it, default path should be `src/main/resources`)
2. Create services file `META-INF/services/io.flutter.embedding.engine.plugins.FlutterPlugin` in java resource folder
3. Add your plugin implementation classes for example```
com.example.MyFlutterPluginA
com.example.MyFlutterPluginB
com.example.MyFlutterPluginC
```