29
29
30
30
public class FlutterWebView implements PlatformView , MethodCallHandler {
31
31
private static final String JS_CHANNEL_NAMES_FIELD = "javascriptChannelNames" ;
32
- private final InputAwareWebView webView ;
32
+ private final WebView webView ;
33
33
private final MethodChannel methodChannel ;
34
34
private final FlutterWebViewClient flutterWebViewClient ;
35
35
private final Handler platformThreadHandler ;
@@ -92,7 +92,13 @@ public void onProgressChanged(WebView view, int progress) {
92
92
DisplayManager displayManager =
93
93
(DisplayManager ) context .getSystemService (Context .DISPLAY_SERVICE );
94
94
displayListenerProxy .onPreWebViewInitialization (displayManager );
95
- webView = new InputAwareWebView (context , containerView );
95
+
96
+ Boolean usesHybridComposition = (Boolean ) params .get ("usesHybridComposition" );
97
+ webView =
98
+ (usesHybridComposition )
99
+ ? new WebView (context )
100
+ : new InputAwareWebView (context , containerView );
101
+
96
102
displayListenerProxy .onPostWebViewInitialization (displayManager );
97
103
98
104
platformThreadHandler = new Handler (context .getMainLooper ());
@@ -140,7 +146,9 @@ public View getView() {
140
146
// of Flutter but used as an override anyway wherever it's actually defined.
141
147
// TODO(mklim): Add the @Override annotation once flutter/engine#9727 rolls to stable.
142
148
public void onInputConnectionUnlocked () {
143
- webView .unlockInputConnection ();
149
+ if (webView instanceof InputAwareWebView ) {
150
+ ((InputAwareWebView ) webView ).unlockInputConnection ();
151
+ }
144
152
}
145
153
146
154
// @Override
@@ -150,7 +158,9 @@ public void onInputConnectionUnlocked() {
150
158
// of Flutter but used as an override anyway wherever it's actually defined.
151
159
// TODO(mklim): Add the @Override annotation once flutter/engine#9727 rolls to stable.
152
160
public void onInputConnectionLocked () {
153
- webView .lockInputConnection ();
161
+ if (webView instanceof InputAwareWebView ) {
162
+ ((InputAwareWebView ) webView ).lockInputConnection ();
163
+ }
154
164
}
155
165
156
166
// @Override
@@ -160,7 +170,9 @@ public void onInputConnectionLocked() {
160
170
// of Flutter but used as an override anyway wherever it's actually defined.
161
171
// TODO(mklim): Add the @Override annotation once stable passes v1.10.9.
162
172
public void onFlutterViewAttached (View flutterView ) {
163
- webView .setContainerView (flutterView );
173
+ if (webView instanceof InputAwareWebView ) {
174
+ ((InputAwareWebView ) webView ).setContainerView (flutterView );
175
+ }
164
176
}
165
177
166
178
// @Override
@@ -170,7 +182,9 @@ public void onFlutterViewAttached(View flutterView) {
170
182
// of Flutter but used as an override anyway wherever it's actually defined.
171
183
// TODO(mklim): Add the @Override annotation once stable passes v1.10.9.
172
184
public void onFlutterViewDetached () {
173
- webView .setContainerView (null );
185
+ if (webView instanceof InputAwareWebView ) {
186
+ ((InputAwareWebView ) webView ).setContainerView (null );
187
+ }
174
188
}
175
189
176
190
@ Override
@@ -425,7 +439,9 @@ private void updateUserAgent(String userAgent) {
425
439
@ Override
426
440
public void dispose () {
427
441
methodChannel .setMethodCallHandler (null );
428
- webView .dispose ();
442
+ if (webView instanceof InputAwareWebView ) {
443
+ ((InputAwareWebView ) webView ).dispose ();
444
+ }
429
445
webView .destroy ();
430
446
}
431
447
}
0 commit comments