initialize method
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 ?? false
},
);
_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(
'video_stream/cameraEvents$_textureId')
.receiveBroadcastStream()
.listen(_listener);
_creatingCompleter!.complete();
return _creatingCompleter!.future;
}