Skip to content

Commit

Permalink
Add PluginRegistry.Registrar#view() (flutter#3900)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tvolkert authored Jul 19, 2017
1 parent 61c4898 commit 488584f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public BinaryMessenger messenger() {
return flutterView;
}

@Override
public FlutterView view() {
return flutterView;
}

/**
* Publishes a value associated with the plugin being registered.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import android.app.Activity;
import android.content.Intent;
import io.flutter.view.FlutterView;

/**
* Registry used by plugins to set up interaction with Android APIs.
Expand Down Expand Up @@ -73,6 +74,12 @@ interface Registrar {
*/
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.
*
Expand Down

0 comments on commit 488584f

Please sign in to comment.