initialize method
Initializes the camera on the device.
Throws a CameraException if the initialization fails.
Implementation
Future<void> initialize() async {
if (_isDisposed) {
return Future<void>.value();
}
try {
_creatingCompleter = Completer<void>();
final Map<String, dynamic> reply =
(await _channel.invokeMapMethod<String, dynamic>(
'initialize',
<String, dynamic>{
'cameraName': description.name,
'resolutionPreset': serializeResolutionPreset(resolutionPreset),
'streamingPreset':
serializeResolutionPreset(streamingPreset ?? resolutionPreset),
'enableAudio': enableAudio,
'enableAndroidOpenGL': androidUseOpenGL
},
))!;
_textureId = reply['textureId'];
value = value.copyWith(
isInitialized: true,
previewSize: Size(
reply['previewWidth'].toDouble(),
reply['previewHeight'].toDouble(),
),
previewQuarterTurns: reply['previewQuarterTurns'],
);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
_eventSubscription = EventChannel(
'plugins.flutter.io/rtmp_publisher/cameraEvents$_textureId')
.receiveBroadcastStream()
.listen(_listener);
_creatingCompleter!.complete();
return _creatingCompleter!.future;
}