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 as ft
import flet_flashlight as ffl
def main(page: ft.Page):
async def turn_on_flashlight():
await ffl.Flashlight().on()
async def turn_off_flashlight():
await ffl.Flashlight().off()
page.add(
ft.Button("Turn On Flashlight", on_click=turn_on_flashlight),
ft.Button("Turn Off Flashlight", on_click=turn_off_flashlight),
)
ft.run(main)
Description#
Inherits: Service
A control to use FlashLight. Works on iOS and Android.
Methods
-
is_available–Checks if the flashlight is available on the device.
-
off–Turns the flashlight off.
-
on–Turns the flashlight on.