activateCamera method

Future<void> activateCamera({
  1. required void setState(
    1. void callback()
    ),
  2. required bool mounted(),
})

Implementation

Future<void> activateCamera({
  required void Function(void Function() callback) setState,
  required bool Function() mounted,
}) async {
  if (!is_camera_init) {
    return;
  }
  if (!is_select_camera) {
    return;
  }
  if (isMobile) {
    try {
      await camera_mobile_controller.initialize();
      if (!mounted.call()) {
        return;
      }
      is_camera_active = true;

      setState(() {});
    } catch (e) {
      if (kDebugMode) {
        print(e);
      }
    }
  } else if (isDesktop) {
    if (Platform.isWindows) {
      await camera_windows.initializeCamera(camera_id);
      is_camera_active = true;
      setState(() {});
    }
  }
}