Skip to content

Commit 488584f

Browse files
authored
Add PluginRegistry.Registrar#view() (flutter#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.
1 parent 61c4898 commit 488584f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

shell/platform/android/io/flutter/app/FlutterActivityDelegate.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ public BinaryMessenger messenger() {
289289
return flutterView;
290290
}
291291

292+
@Override
293+
public FlutterView view() {
294+
return flutterView;
295+
}
296+
292297
/**
293298
* Publishes a value associated with the plugin being registered.
294299
*

shell/platform/android/io/flutter/plugin/common/PluginRegistry.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import android.app.Activity;
88
import android.content.Intent;
9+
import io.flutter.view.FlutterView;
910

1011
/**
1112
* Registry used by plugins to set up interaction with Android APIs.
@@ -73,6 +74,12 @@ interface Registrar {
7374
*/
7475
BinaryMessenger messenger();
7576

77+
/**
78+
* Returns the {@link FlutterView} that's instantiated by this plugin's
79+
* {@link #activity() activity}.
80+
*/
81+
FlutterView view();
82+
7683
/**
7784
* Publishes a value associated with the plugin being registered.
7885
*

0 commit comments

Comments
 (0)