Skip to content

Instantly share code, notes, and snippets.

@matthew-carroll
Created May 22, 2019 21:12
Show Gist options
  • Save matthew-carroll/9013880d8bc6cb463d75a97571252f0d to your computer and use it in GitHub Desktop.
Save matthew-carroll/9013880d8bc6cb463d75a97571252f0d to your computer and use it in GitHub Desktop.
New Android embedding, new and old plugins, or all old plugins.
// This example assumes that the developer is using the new Android embedding
// API, some plugins that use dart-side initialization, and some old plugins
// that have no concept of dart-side initialization.
//
// This example would be the same even if all used plugins were old (no dart-side
// initialization).
public class MainActivity extends FlutterActivity {
@Override
protected void onFlutterEngineCreated(@NonNull FlutterEngine engine) {
// We register the GeneratedPluginLoader for the plugins that use
// dart-side initialization.
engine.setPluginLoader(new GeneratedPluginLoader());
// The new Android embedding comes with a shim for old plugins. We use
// that shim to initialize all the old-style plugins that don't support
// dart-side initialization. The following line will cause all the old
// plugins to be initialized right now and connected to the give engine.
// This is the standard behavior today.
new GeneratedShimPluginRegistrant().registerWith(engine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment