A Flutter adapter for Expo Universal Modules. It requires
@unimodules/core to be installed and linked.
Getting Started #
Add the plugin as a dependency in your Flutter project's
dependencies: expo_flutter_adapter: ^0.1.0
To install it directly from our git repo, specify the dependency as shown below:
dependencies: expo_flutter_adapter: git: url: git://github.com/expo/expo.git path: packages/expo-flutter-adapter
In your Android app's
Import the adapter's java package by adding
import io.expo.expoflutteradapter.ExpoFlutterAdapterPlugin;to your imports section.
Add a call to
initializemethod after the
GeneratedPluginRegistrant.registerWith(this);call by adding
If you're simply adding this to consume other previously developed Flutter Universal Module plugins, you won't have to read past this point.
If you're developing a Universal Module Flutter plugin, you are probably interested in the
ExpoModulesProxy for interfacing with native Universal Modules from Dart.
You can import the module proxy by adding this line to the beginning of your dart file:
This file contains two classes:
The Dart API of the
ExpoModuleProxy is as follows:
static Future<dynamic> callMethod(String moduleName, String methodName, [List<dynamic> arguments = const ])
ExpoModuleProxy.callMethod is a static method that your plugin can use to call a method exposed by the specified Universal Module. The parameter names should be pretty self-explanatory.
static Future<dynamic> getConstant(String moduleName, String constantName)
ExpoModuleProxy.getConstant is a static method that your plugin can use to retrieve a constant exposed by the specified Universal Module.
static Stream<ExpoEvent> get events
ExpoModuleProxy.events is a stream of all events being emitted by the Universal Module core. As a plugin developer, you can filter by event names to expose module-specific events to your consumers. See accelerometer.dart from the expo_sensors package for an example.
ExpoEvent is a data class streamed from
ExpoModuleProxy.events that has the following properties:
expoEvent.name (String): the name of the incoming event.
expoEvent.body (Map<String, dynamic>): the payload of the incoming event.
Pro Tip: See other Universal Module Flutter plugins in the packages directory of this repository for more examples of how this adapter is used.
- This initial release allows Unimodule Flutter plugin developers to call exported methods from unimodules, register new modules on the Android platform, get constants from unimodules, and access the stream of events that are being emitted by the registered modules.
- This release updates unimodule framework dependencies after those dependencies were renamed to ensure new installs work properly.
A Test Suite for Expo Modules on Flutter.
Getting Started #
Grab the universal modules themselves (currently distributed as NPM packages) by running
yarnin this directory.
Assuming Flutter is already installed, use your IDE of choice to run the app or use
flutter runat the command-line with a device attached to build, install, and launch the app on your device.
Note: if you see an error on the iOS side about CocoaPods complaining about a pre-release version of the unimodule it's trying to link, run
pod update in the
example/ios folder. That should resolve your issue.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: expo_flutter_adapter: ^0.1.1
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
This package is not analyzed, because it is discontinued.
|Dart SDK||>=2.0.0-dev.58.0 <3.0.0|