Open taimoor522 opened 2 years ago
I want to turn on and off flashlight inside a timer.periodic but flash is not turning on....?
FlutterIsolate.spawn(turnOnFlashLight, [ flashLightBlinks, flashLightBlinksDelay, prefs, ]); --------------------------------------------------------------------------------- void turnOnFlashLight(List<dynamic> l) { int flashLightBlinks = l[0]; int flashLightBlinksDelay = l[1]; SharedPreferences prefs = l[2]; int i = flashLightBlinks; Timer.periodic( Duration(seconds: flashLightBlinksDelay + 1), (t) async { print('LOG : Timer running $i '); if (i-- > 0 && !(prefs.getBool('forceStopFlashlight') ?? false)) { print('LOG : inside flashon'); try { TorchLight.enableTorch(); await Future.delayed(const Duration(seconds: 1)); TorchLight.disableTorch(); await Future.delayed(Duration(seconds: flashLightBlinksDelay)); } catch (_) { print('LOG : flashtimer cancel'); TorchLight.disableTorch(); t.cancel(); } } else { TorchLight.disableTorch(); t.cancel(); } }, ); }
Probably the same recurring issue with incompatible plugins. This is unlikely to be fixed in the near term, but can you post a link to the torchlight Android/iOS plugin code for future reference.
I want to turn on and off flashlight inside a timer.periodic but flash is not turning on....?