getCameraDeviceId function
Implementation
Future<String> getCameraDeviceId(front) async {
List<MediaDeviceInfo> videoDevices = (await navigator.mediaDevices.enumerateDevices()).where((element) => element.kind == 'videoinput').toList();
if (videoDevices.isEmpty) {
throw Exception("No camera found");
}
if (videoDevices.length == 1) {
return videoDevices.first.deviceId;
}
return (front ? videoDevices.first.deviceId : videoDevices.last.deviceId);
}