buildView method

  1. @override
Widget buildView(
  1. int creationId,
  2. PlatformViewCreatedCallback onPlatformViewCreated, {
  3. Map<String, dynamic> params = const <String, dynamic>{},
})
override

Implementation

@override
Widget buildView(
  int creationId,
  PlatformViewCreatedCallback onPlatformViewCreated, {
  Map<String, dynamic> params = const <String, dynamic>{},
}) {
  params['creationId'] = creationId;
  if (defaultTargetPlatform == TargetPlatform.android) {
    const viewType = 'oneplusdream/video_player_android';
    return PlatformViewLink(
      viewType: viewType,
      surfaceFactory: (context, controller) {
        return AndroidViewSurface(
          controller: controller as AndroidViewController,
          gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
          hitTestBehavior: PlatformViewHitTestBehavior.opaque,
        );
      },
      onCreatePlatformView: (p) {
        return PlatformViewsService.initSurfaceAndroidView(
          id: p.id,
          viewType: viewType,
          layoutDirection: TextDirection.ltr,
          creationParams: params,
          creationParamsCodec: const StandardMessageCodec(),
          onFocus: () {
            p.onFocusChanged(true);
          },
        )
          ..addOnPlatformViewCreatedListener(p.onPlatformViewCreated)
          ..addOnPlatformViewCreatedListener(onPlatformViewCreated)
          ..create();
      },
    );
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    return UiKitView(
      viewType: 'oneplusdream/video_player_ios',
      onPlatformViewCreated: onPlatformViewCreated,
      creationParams: params,
      creationParamsCodec: const StandardMessageCodec(),
    );
  }

  return Text(
      '$defaultTargetPlatform is not yet supported by the maps plugin');
}