enable method
Enables the torch (flashlight) on the device.
Optionally specify a duration to automatically turn off the torch after the specified time.
mode - The flash mode to use (torch or flash).
Implementation
Future<void> enable(
{Duration? duration, FlashMode mode = FlashMode.torch}) async {
_cancelAllTimers();
await TorchFlashlight.enableTorchFlashlight(duration: duration, mode: mode);
_isEnabled = true;
if (duration != null) {
_autoOffTimer = Timer(duration, () async {
_isEnabled = false;
});
}
}