toggleFlashlight method

Future<bool> toggleFlashlight({
  1. required bool state,
})

Toggles the native device flashlight (Torch) inside the AR Session. Returns true if successful, false if unsupported or failed.

Implementation

Future<bool> toggleFlashlight({required bool state}) async {
  try {
    final bool? success = await _channel.invokeMethod<bool>('toggleFlashlight', {
      'state': state,
    });
    return success ?? false;
  } catch (e) {
    print('Error caught toggling AR flashlight: ' + e.toString());
    return false;
  }
}