public interface PlatformView
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose this platform view.
|
View |
getView()
Returns the Android view to be embedded in the Flutter hierarchy.
|
default void |
onFlutterViewAttached(View flutterView)
Called by the
FlutterEngine that owns this PlatformView when
the Android View responsible for rendering a Flutter UI is associated
with the FlutterEngine . |
default void |
onFlutterViewDetached()
Called by the
FlutterEngine that owns this PlatformView when
the Android View responsible for rendering a Flutter UI is detached
and disassociated from the FlutterEngine . |
default void |
onInputConnectionLocked()
Callback fired when the platform's input connection is locked, or should be used.
|
default void |
onInputConnectionUnlocked()
Callback fired when the platform input connection has been unlocked.
|
View getView()
default void onFlutterViewAttached(@NonNull View flutterView)
FlutterEngine
that owns this PlatformView
when
the Android View
responsible for rendering a Flutter UI is associated
with the FlutterEngine
.
This means that our associated FlutterEngine
can now render a UI and
interact with the user.
Some platform views may have unusual dependencies on the View
that
renders Flutter UIs, such as unique keyboard interactions. That View
is provided here for those purposes. Use of this View
should be avoided
if it is not absolutely necessary, because depending on this View
will
tend to make platform view code more brittle to future changes.
default void onFlutterViewDetached()
FlutterEngine
that owns this PlatformView
when
the Android View
responsible for rendering a Flutter UI is detached
and disassociated from the FlutterEngine
.
This means that our associated FlutterEngine
no longer has a rendering
surface, or a user interaction surface of any kind.
This platform view must release any references related to the Android View
that was provided in onFlutterViewAttached(View)
.
void dispose()
The PlatformView
object is unusable after this method is called.
Plugins implementing PlatformView
must clear all references to the View object and the PlatformView
after this method is called. Failing to do so will result in a memory leak.
References related to the Android View
attached in
onFlutterViewAttached(View)
must be released in dispose()
to avoid memory
leaks.
default void onInputConnectionLocked()
TextInputPlugin#lockPlatformViewInputConnection
.
This hook only exists for rare cases where the plugin relies on the state of the input connection. This probably doesn't need to be implemented.
default void onInputConnectionUnlocked()
TextInputPlugin#lockPlatformViewInputConnection
.
This hook only exists for rare cases where the plugin relies on the state of the input connection. This probably doesn't need to be implemented.