onPlatformViewCreated method

void onPlatformViewCreated(
  1. int id
)

Được gọi từ view khi native PlatformView đã sẵn sàng.

Implementation

void onPlatformViewCreated(int id) {
  const String baseChannelName = "com.plugin.camera_native.native_camera_view/camera_method_channel";
  final String channelName = Platform.isIOS ? '${baseChannelName}_ios_$id' : '${baseChannelName}_$id';

  final platformChannel = MethodChannel(channelName);
  _nativeServiceController = CameraController(channel: platformChannel);

  platformChannel.setMethodCallHandler(_handleNativeMethodCall);

  onControllerCreated(_nativeServiceController!);

  _nativeServiceController!.initialize();

  debugPrint('PlatformView (id: $id) created. CameraController initialized on channel: $channelName');
}