A Flutter adapter for Expo Universal Modules. It requires
expo-core to be installed and linked.
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.