expo_flutter_adapter 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 26

expo_flutter_adapter #

A Flutter adapter for Expo Universal Modules. It requires @unimodules/core to be installed and linked.

Getting Started #

Installation #

Add the plugin as a dependency in your Flutter project's pubspec.yaml file.

  expo_flutter_adapter: ^0.1.0

To install it directly from our git repo, specify the dependency as shown below:

      url: git://github.com/expo/expo.git
      path: packages/expo-flutter-adapter

Configuration #

In your Android app's MainActivity.java file:

  1. Import the adapter's java package by adding import io.expo.expoflutteradapter.ExpoFlutterAdapterPlugin; to your imports section.

  2. Add a call to ExpoFlutterAdapterPlugin's initialize method after the GeneratedPluginRegistrant.registerWith(this); call by adding ExpoFlutterAdapterPlugin.initialize(); after it.

Usage #

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:

import 'package:expo_flutter_adapter/expo_modules_proxy.dart';

This file contains two classes: ExpoModulesProxy and ExpoEvent.

ExpoModulesProxy #

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 #

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.

Changelog #

0.1.0 #

  • 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.

0.1.1 #

  • This release updates unimodule framework dependencies after those dependencies were renamed to ensure new installs work properly.


test_suite_flutter #

A Test Suite for Expo Modules on Flutter.

Getting Started #

  • Grab the universal modules themselves (currently distributed as NPM packages) by running yarn in this directory.

  • Assuming Flutter is already installed, use your IDE of choice to run the app or use flutter run at 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:

  expo_flutter_adapter: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ 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:

import 'package:expo_flutter_adapter/expo_flutter_adapter.dart';
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]
Learn more about scoring.

This package is not analyzed, because it is discontinued.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <3.0.0