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 5 package io.flutter.plugin.platform; 6 7 import android.annotation.SuppressLint; 8 import android.view.View; 9 10 /** 11 * A handle to an Android view to be embedded in the Flutter hierarchy. 12 */ 13 public interface PlatformView { 14 /** 15 * Returns the Android view to be embedded in the Flutter hierarchy. 16 */ getView()17 View getView(); 18 19 /** 20 * Dispose this platform view. 21 * 22 * <p>The {@link PlatformView} object is unusable after this method is called. 23 * 24 * <p>Plugins implementing {@link PlatformView} must clear all references to the View object and the PlatformView 25 * after this method is called. Failing to do so will result in a memory leak. 26 */ dispose()27 void dispose(); 28 29 /** 30 * Callback fired when the platform's input connection is locked, or should be used. See also 31 * {@link TextInputPlugin#lockPlatformViewInputConnection}. 32 * 33 * <p>This hook only exists for rare cases where the plugin relies on the state of the input 34 * connection. This probably doesn't need to be implemented. 35 */ 36 // Default interface methods are supported on all min SDK versions of Android. 37 @SuppressLint("NewApi") onInputConnectionLocked()38 default void onInputConnectionLocked() {}; 39 40 /** 41 * Callback fired when the platform input connection has been unlocked. See also 42 * {@link TextInputPlugin#lockPlatformViewInputConnection}. 43 * 44 * <p>This hook only exists for rare cases where the plugin relies on the state of the input 45 * connection. This probably doesn't need to be implemented. 46 */ 47 // Default interface methods are supported on all min SDK versions of Android. 48 @SuppressLint("NewApi") onInputConnectionUnlocked()49 default void onInputConnectionUnlocked() {}; 50 } 51