createCamera method

  1. @override
Future<int> createCamera(
  1. CameraDescription cameraDescription,
  2. ResolutionPreset? resolutionPreset, {
  3. bool enableAudio = false,
})

Creates an uninitialized camera instance and returns the cameraId.

Implementation

@override
Future<int> createCamera(
  CameraDescription cameraDescription,
  ResolutionPreset? resolutionPreset, {
  bool enableAudio = false,
}) async {
  try {
    final Map<String, dynamic>? reply =
        await _channel.invokeMapMethod<String, dynamic>('create', <String, dynamic>{
      'cameraName': cameraDescription.name,
      'resolutionPreset':
          resolutionPreset != null ? _serializeResolutionPreset(resolutionPreset) : null,
      'enableAudio': enableAudio,
    });

    return reply!['cameraId']! as int;
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}