Flashlight Service
Overview
Flashlight service allows controlling the device's torch/flashlight within a Flet application.flashlight package.flet.Service.Platform Support
Installation
1. **Add Dependency:**
- Using uv:
uv add flet-flashlight
- Using pip:
pip install flet-flashlight
2. **Project Configuration:**
- Manually add flet-flashlight to your requirements.txt or pyproject.toml file.Usage Example
import flet as ft
import flet_flashlight as ffldef 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)
Methods
is_available()**async
- **Description:** Checks if the flashlight hardware is available on the device.
- **Usage:** await ffl.Flashlight().is_available()on()**async
- **Description:** Turns the device's flashlight on.
- **Usage:** await ffl.Flashlight().on()off()**async
- **Description:** Turns the device's flashlight off.
- **Usage:** await ffl.Flashlight().off()
Previous
arrow_back
Creating an extension