buildView method

  1. @override
Widget buildView(
  1. int viewId,
  2. void onPlatformViewCreated(
    1. int
    )
)
override

Implementation

@override
Widget buildView(int viewId, void Function(int) onPlatformViewCreated) {
  const String viewType = '<platform-view-type>';

  final platform = defaultTargetPlatform;
  switch (platform) {
    case TargetPlatform.android:
      return AndroidView(
        viewType: viewType,
        onPlatformViewCreated: onPlatformViewCreated,
        creationParams: <String, dynamic>{
          'id': viewId,
        },
        creationParamsCodec: const StandardMessageCodec(),
      );
    case TargetPlatform.iOS:
      return UiKitView(
        viewType: viewType,
        onPlatformViewCreated: onPlatformViewCreated,
        creationParams: <String, dynamic>{
          'id': viewId,
        },
        creationParamsCodec: const StandardMessageCodec(),
      );
    default:
      throw UnsupportedError(
          'Platform $platform is not supported by this plugin');
  }
}