initNativeView method

void initNativeView()

Implementation

void initNativeView() {
  if (nativeView != null) {
    onPlatformViewCreated(viewId);
    return;
  }
  if (Platform.isAndroid) {
    nativeView = AndroidView(
      viewType: viewType,
      onPlatformViewCreated: (int viewId) {
        this.viewId = viewId;
        onPlatformViewCreated(viewId);
      },
      creationParams: <String, dynamic>{
        "native_view_type": nativeViewType.idx
      },
      creationParamsCodec: const StandardMessageCodec(),
    );
  } else if (Platform.isIOS) {
    nativeView = UiKitView(
      viewType: viewType,
      onPlatformViewCreated: (int viewId) {
        this.viewId = viewId;
        onPlatformViewCreated(viewId);
      },
      creationParams: const {},
      creationParamsCodec: const StandardMessageCodec(),
    );
  } else {
    throw UnsupportedError("Unsupported Platform");
  }
}