androidPlatformView method
Widget
androidPlatformView(
- String viewType,
- ValueNotifier<
bool> isDetachedValueNotifier, - ValueNotifier<
bool> isLoadingValueNotifier, - Widget? faceMaskOverlay,
- Widget? onLoadingWidget,
- Map<
String, dynamic> creationParams,
Implementation
Widget androidPlatformView(
String viewType,
ValueNotifier<bool> isDetachedValueNotifier,
ValueNotifier<bool> isLoadingValueNotifier,
Widget? faceMaskOverlay,
Widget? onLoadingWidget,
Map<String, dynamic> creationParams) {
return PlatformViewLink(
viewType: viewType,
surfaceFactory: (
BuildContext context,
PlatformViewController controller,
) {
return ValueListenableBuilder(
valueListenable: isDetachedValueNotifier,
builder: (context, isDetached, _) {
return ValueListenableBuilder(
valueListenable: isLoadingValueNotifier,
builder: (context, isLoading, child) {
return Stack(
children: [
isDetached
? const SizedBox.shrink()
: PlatformViewSurface(
controller: controller,
gestureRecognizers: const <Factory<
OneSequenceGestureRecognizer>>{},
hitTestBehavior:
PlatformViewHitTestBehavior.opaque,
),
faceMaskOverlay ?? const SizedBox.shrink(),
isLoading || isDetached
? onLoadingWidget ??
const Center(
child: CircularProgressIndicator(),
)
: const SizedBox.shrink(),
],
);
},
);
});
},
onCreatePlatformView: (PlatformViewCreationParams params) {
return PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: viewType,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onFocus: () {
params.onFocusChanged(true);
},
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
);
}