startSocketCamExtension static method
Implementation
static Future<void> startSocketCamExtension(
int? clientHandle, Function callback) async {
_readyCompleter = Completer<void>();
// Setup listener BEFORE starting the extension to avoid missing events
_subscription =
eventChannel.receiveBroadcastStream().listen((dynamic event) {
callback(event);
if (_readyCompleter != null &&
!_readyCompleter!.isCompleted &&
event is Map &&
event['status'] == 2) {
_readyCompleter!.complete();
}
});
try {
await platform.invokeMethod('startSocketCamExtension',
<String, int?>{'clientHandle': clientHandle});
} catch (e) {
await _subscription?.cancel();
_subscription = null;
_readyCompleter = null;
throw e.toString();
}
return _readyCompleter!.future;
}