Replies: 1 comment
-
once check and request android.permission.FLASHLIGHT permission OLD VERSION API import flet as ft
def main(page: ft.Page):
flashLight = ft.Flashlight()
page.overlay.append(flashLight)
def flashLight_toggled(e):
flashLight.toggle(wait_timeout=5)
page.add(
ft.ElevatedButton(
text="toogle",
on_click=flashLight_toggled
)
)
ft.app(target=main) in flutter: bool _onn= false;
void _onoff() async{
try {
final isTorchAvailable = await TorchLight.isTorchAvailable();
if (isTorchAvailable){
if(!_onn){
TorchLight.enableTorch();
_onn=true;
}
else{
TorchLight.disableTorch();
_onn=false;
}
}
} on Exception catch (_) {
// Handle error
}
}
....
.....
......
floatingActionButton: FloatingActionButton(
onPressed: _onoff,
tooltip: 'Turn On/Off',
child: const Icon(Icons.add),
), |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
When running on a physical device, it gives the error "unknown flashlight module" and also swears at lambda. I use Python 3.12.4 and Android 7. Please tell me how to fix it? Thank you in advance.
Code sample
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions