Flashlight#
Control the device torch/flashlight in your Flet app via the flet-flashlight extension, built on top of Flutter's flashlight package.
Platform Support#
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|---|---|---|---|---|---|---|
| Supported | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
Usage#
Add flet-flashlight to your project dependencies:
Example#
import flet_flashlight as ffl
import flet as ft
def main(page: ft.Page):
async def toggle_flashlight():
flashlight = ffl.Flashlight()
await flashlight.toggle()
page.add(ft.TextButton("toggle", on_click=toggle_flashlight))
ft.run(main)
Description#
Inherits: Service
A control to use FlashLight. Works on iOS and Android.
Properties
-
on–Whether the flashlight is currently turned on.
Events
-
on_error(ControlEventHandler[Flashlight] | None) –Fires when an error occurs.
Methods
-
is_available–Checks if the flashlight is available on the device.
-
toggle–Toggles the flashlight on and off.
-
turn_off–Turns the flashlight off.
-
turn_on–Turns the flashlight on.
Properties#
Events#
on_error
#
on_error: ControlEventHandler[Flashlight] | None = None
Fires when an error occurs.
The data property of the event handler argument
contains information on the error.
Methods#
See also:
- FlashlightException
- FlashlightEnableException
- FlashlightDisableException