androidPlatformView method

Widget androidPlatformView(
  1. String viewType,
  2. ValueNotifier<bool> isDetachedValueNotifier,
  3. ValueNotifier<bool> isLoadingValueNotifier,
  4. Widget? faceMaskOverlay,
  5. Widget? onLoadingWidget,
  6. 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();
    },
  );
}