Introduction to Flet
Flet is a framework that allows you to build interactive multi-platform apps in Python based on Flutter by Google.
Your first Flet app
Here is a simple example of a counter application built with Flet:
import flet as ft
def main(page: ft.Page):
page.title = "Flet counter example"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
def minus_click(e):
txt_number.value = str(int(txt_number.value) - 1)
page.update()
def plus_click(e):
txt_number.value = str(int(txt_number.value) + 1)
page.update()
page.add(
ft.Row(
[
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
txt_number,
ft.IconButton(ft.icons.ADD, on_click=plus_click),
],
alignment=ft.MainAxisAlignment.CENTER,
)
)
ft.app(target=main)
Key Features
- Real-time updates without page refreshes.
- Extensive set of Flutter controls.
- Deploy as a web, desktop, or mobile app.
- Built-in support for light/dark modes.
Previous
arrow_back
Homepage