Add PluginRegistry.Registrar#view() (flutter/engine#3900)

Sometimes, plugin instances need access to the `FlutterView`.
They can currently cast the `messenger()`, but that's fragile.
This adds API support for getting the view from the registry.
This commit is contained in:
Todd Volkert
2017-07-18 19:16:15 -07:00
committed by GitHub
parent afbb9c7eb6
commit 27c20427cc
2 changed files with 12 additions and 0 deletions

View File

@@ -289,6 +289,11 @@ public final class FlutterActivityDelegate
return flutterView;
}
@Override
public FlutterView view() {
return flutterView;
}
/**
* Publishes a value associated with the plugin being registered.
*

View File

@@ -6,6 +6,7 @@ package io.flutter.plugin.common;
import android.app.Activity;
import android.content.Intent;
import io.flutter.view.FlutterView;
/**
* Registry used by plugins to set up interaction with Android APIs.
@@ -73,6 +74,12 @@ public interface PluginRegistry {
*/
BinaryMessenger messenger();
/**
* Returns the {@link FlutterView} that's instantiated by this plugin's
* {@link #activity() activity}.
*/
FlutterView view();
/**
* Publishes a value associated with the plugin being registered.
*