createView static method
Implementation
static Widget createView(BuildContext context, ImpulsePlayerController controller) {
var platform = Theme.of(context).platform;
switch (platform) {
case TargetPlatform.android:
const Map<String, dynamic> creationParams = <String, dynamic>{};
return PlatformViewLink(
viewType: ImpulsePlayerPluginConstants.ViewTag,
surfaceFactory: (context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<HorizontalDragGestureRecognizer>(() => HorizontalDragGestureRecognizer()),
},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (params) {
return PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: ImpulsePlayerPluginConstants.ViewTag,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onFocus: () {
params.onFocusChanged(true);
},
)
..addOnPlatformViewCreatedListener((id) {
_attachs[controller.id] = id;
_controllers[controller.id] = controller;
})
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
);
case TargetPlatform.iOS:
return UiKitView(
viewType: ImpulsePlayerPluginConstants.ViewTag,
onPlatformViewCreated: (int id) {
_attachs[controller.id] = id;
_controllers[controller.id] = controller;
},
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<HorizontalDragGestureRecognizer>(() => HorizontalDragGestureRecognizer()),
},
);
default:
return const Center(child: Text("This platform is not supported."));
}
}