onInit method
override
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() async {
_cameraWorker = ever(camera, (e) => initRenderer());
_devicesSubscription = MediaUtils.onDeviceChange.listen(
(e) => devices.value = e.video().toList(),
);
try {
_permissionSubscription = await WebUtils.cameraPermission();
devices.value = await MediaUtils.enumerateDevices(
MediaDeviceKind.videoInput,
);
initRenderer();
} on UnsupportedError {
error.value = 'err_media_devices_are_null'.l10n;
} catch (e) {
if (e.toString().contains('Permission denied')) {
error.value = 'err_camera_permission_denied'.l10n;
} else {
error.value = e.toString();
rethrow;
}
}
super.onInit();
}