setTorchMode method

Future<void> setTorchMode(
  1. bool enabled
)

Turns the active camera's torch (flashlight) on or off. The platform returns the actual resulting torch state, which is cached in isTorchEnabled — so the cache stays correct even when the call fails or the active camera has no torch (e.g. most front cameras). On a swallowed platform error the cached state is left unchanged.

Implementation

Future<void> setTorchMode(bool enabled) async {
  final result = await _invoke<bool>('setTorchMode', {'enabled': enabled});
  if (result != null) _torchEnabled = result;
}