createNativeView static method

Widget createNativeView(
  1. dynamic created(
    1. int viewId
    ),
  2. bool zOrderMediaOverlay,
  3. String mScaleType,
  4. int uid, {
  5. Key? key,
})

Creates the video renderer Widget. The Widget is identified by viewI}d, the operation and layout of the Widget are managed by the app.

Implementation

static Widget createNativeView(Function(int viewId) created,
 bool zOrderMediaOverlay, String mScaleType, int uid,
 {Key? key}) {
    print('*' + key.toString());
    final paramValue = {
 'setZOrderMediaOverlay': {
   'mediaOverLay': zOrderMediaOverlay,
   'scaleType': mScaleType,
   'uid': uid,
 },
    };

    if (kIsWeb) {
 return HtmlElementView(
     key: key,
     viewType: 'EnxPlayer',
     onPlatformViewCreated: (viewId) {
       created(viewId);
     },
     creationParams: paramValue);
    } else {
 if (Platform.isIOS) {
   return UiKitView(
     key: key,
     viewType: 'EnxPlayer',
     onPlatformViewCreated: (viewId) {
       print('' + viewId.toString());
       created(viewId);
       print('view created' + viewId.toString());
     },
   );
 } else {
   return AndroidView(
     key: key,
     viewType: 'EnxPlayer',
     onPlatformViewCreated: (viewId) {
       print("Android Platform view created: $viewId");
       // Add a delay before interacting with the platform view
       WidgetsBinding.instance.addPostFrameCallback((_) {
         // Safely interact with the platform view after the frame is drawn
         created(viewId); // Now you can safely interact with the view
       });

     },
     creationParams: paramValue,
     creationParamsCodec: const StandardMessageCodec(),
   );
 }
    }
  }