setTorch method

Future<bool> setTorch(
  1. bool enable
)

Turn the camera torch on (enable = true) or off (enable = false). Returns the actual torch state after the call — false when the device has no torch or the call is made before the view is attached.

Implementation

Future<bool> setTorch(bool enable) async {
  final ch = _channel;
  if (ch == null) return false;
  final result = await ch.invokeMethod<bool>('setTorch', {'enable': enable});
  _torchEnabled = result ?? false;
  return _torchEnabled;
}