setTorchEnabled method
Future<void>
setTorchEnabled(
- bool enabled
)
inherited
Implementation
@override
Future<void> setTorchEnabled(bool enabled) {
if (CallType.VIDEO_CALL != callType) {
return Future.error(IllegalStateException(
"Can't perform operation [setTorchEnabled] for AUDIO call"));
}
try {
if (localStream == null) {
return Future.error(IllegalStateException(
"Can't perform operation [setTorchEnabled], cause 'localStream' not initialised"));
} else {
final videoTrack = localStream!
.getVideoTracks()
.firstWhere((track) => track.kind == 'video');
return videoTrack.hasTorch().then((has) {
if (has) {
return videoTrack.setTorch(enabled);
} else {
return Future.error(IllegalStateException(
"Can't perform operation [setTorchEnabled], cause current camera does not support torch mode"));
}
});
}
} catch (error) {
return Future.error(error);
}
}