Skip to content

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:

uv add flet-flashlight
pip install flet-flashlight  # (1)!
  1. After this, you will have to manually add this package to your requirements.txt or pyproject.toml.

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.

Methods#

is_available async #

is_available()

Checks if the flashlight is available on the device.

off async #

off()

Turns the flashlight off.

on async #

on()

Turns the flashlight on.