text stringlengths 1 372 |
|---|
surfaceFactory: (context, controller) { |
return AndroidViewSurface( |
controller: controller as AndroidViewController, |
gestureRecognizers: const <factory<onesequencegesturerecognizer>>{}, |
hitTestBehavior: PlatformViewHitTestBehavior.opaque, |
); |
}, |
onCreatePlatformView: (params) { |
return PlatformViewsService.initSurfaceAndroidView( |
id: params.id, |
viewType: viewType, |
layoutDirection: TextDirection.ltr, |
creationParams: creationParams, |
creationParamsCodec: const StandardMessageCodec(), |
onFocus: () { |
params.onFocusChanged(true); |
}, |
) |
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) |
..create(); |
}, |
); |
} |
<code_end> |
for more information, see the API docs for: |
<topic_end> |
<topic_start> |
virtual display |
in your dart file, |
for example native_view_example.dart, |
use the following instructions: |
add the following imports: |
<code_start> |
import 'package:flutter/material.dart'; |
import 'package:flutter/services.dart'; |
<code_end> |
implement a build() method: |
<code_start> |
widget build(BuildContext context) { |
// this is used in the platform side to register the view. |
const string viewType = '<platform-view-type>'; |
// pass parameters to the platform side. |
final Map<String, dynamic> creationParams = <string, dynamic>{}; |
return AndroidView( |
viewType: viewType, |
layoutDirection: TextDirection.ltr, |
creationParams: creationParams, |
creationParamsCodec: const StandardMessageCodec(), |
); |
} |
<code_end> |
for more information, see the API docs for: |
<topic_end> |
<topic_start> |
on the platform side |
on the platform side, use the standard |
io.flutter.plugin.platform package |
in either java or kotlin: |
in your native code, implement the following: |
extend io.flutter.plugin.platform.PlatformView |
to provide a reference to the android.view.View |
(for example, NativeView.kt): |
create a factory class that creates an instance of the |
NativeView created earlier |
(for example, NativeViewFactory.kt): |
finally, register the platform view. |
you can do this in an app or a plugin. |
for app registration, |
modify the app’s main activity |
(for example, MainActivity.kt): |
for plugin registration, |
modify the plugin’s main class |
(for example, PlatformViewPlugin.kt): |
in your native code, implement the following: |
extend io.flutter.plugin.platform.PlatformView |
to provide a reference to the android.view.View |
(for example, NativeView.java): |
create a factory class that creates an |
instance of the NativeView created earlier |
(for example, NativeViewFactory.java): |
finally, register the platform view. |
you can do this in an app or a plugin. |
for app registration, |
modify the app’s main activity |
(for example, MainActivity.java): |
for plugin registration, |
modify the plugin’s main file |
(for example, PlatformViewPlugin.java): |
for more information, see the API docs for: |
finally, modify your build.gradle file |
to require one of the minimal android SDK versions: |
<topic_end> |
<topic_start> |
manual view invalidation |
certain android views do not invalidate themselves when their content changes. |
some example views include SurfaceView and SurfaceTexture. |
when your platform view includes these views you are required to |
manually invalidate the view after they have been drawn to |
(or more specifically: after the swap chain is flipped). |
manual view invalidation is done by calling invalidate on the view |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.