Flutter Engine
The Flutter Engine
PlatformView.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.plugin.platform;
6
7import android.annotation.SuppressLint;
8import android.view.View;
9import androidx.annotation.NonNull;
10import androidx.annotation.Nullable;
11
12/** A handle to an Android view to be embedded in the Flutter hierarchy. */
13public interface PlatformView {
14 /** Returns the Android view to be embedded in the Flutter hierarchy. */
15 @Nullable
16 View getView();
17
18 /**
19 * Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this {@code
20 * PlatformView} when the Android {@link View} responsible for rendering a Flutter UI is
21 * associated with the {@link io.flutter.embedding.engine.FlutterEngine}.
22 *
23 * <p>This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} can now
24 * render a UI and interact with the user.
25 *
26 * <p>Some platform views may have unusual dependencies on the {@link View} that renders Flutter
27 * UIs, such as unique keyboard interactions. That {@link View} is provided here for those
28 * purposes. Use of this {@link View} should be avoided if it is not absolutely necessary, because
29 * depending on this {@link View} will tend to make platform view code more brittle to future
30 * changes.
31 */
32 // Default interface methods are supported on all min SDK versions of Android.
33 @SuppressLint("NewApi")
34 default void onFlutterViewAttached(@NonNull View flutterView) {}
35
36 /**
37 * Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this {@code
38 * PlatformView} when the Android {@link View} responsible for rendering a Flutter UI is detached
39 * and disassociated from the {@link io.flutter.embedding.engine.FlutterEngine}.
40 *
41 * <p>This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} no longer
42 * has a rendering surface, or a user interaction surface of any kind.
43 *
44 * <p>This platform view must release any references related to the Android {@link View} that was
45 * provided in {@link #onFlutterViewAttached(View)}.
46 */
47 // Default interface methods are supported on all min SDK versions of Android.
48 @SuppressLint("NewApi")
50
51 /**
52 * Dispose this platform view.
53 *
54 * <p>The {@link PlatformView} object is unusable after this method is called.
55 *
56 * <p>Plugins implementing {@link PlatformView} must clear all references to the View object and
57 * the PlatformView after this method is called. Failing to do so will result in a memory leak.
58 *
59 * <p>References related to the Android {@link View} attached in {@link
60 * #onFlutterViewAttached(View)} must be released in {@code dispose()} to avoid memory leaks.
61 */
62 void dispose();
63
64 /**
65 * Callback fired when the platform's input connection is locked, or should be used.
66 *
67 * <p>This hook only exists for rare cases where the plugin relies on the state of the input
68 * connection. This probably doesn't need to be implemented.
69 */
70 @SuppressLint("NewApi")
72
73 /**
74 * Callback fired when the platform input connection has been unlocked.
75 *
76 * <p>This hook only exists for rare cases where the plugin relies on the state of the input
77 * connection. This probably doesn't need to be implemented.
78 */
79 @SuppressLint("NewApi")
81}
default void onFlutterViewAttached(@NonNull View flutterView)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By default
Definition: switches.h:183