Library Guide

Flet

Build Material Design apps in pure Python โ€” runs on web, desktop and mobile via Flutter.

Flutter-powered Web + desktop + mobile

What Is Flet?

Flet is a Python framework that lets you build cross-platform apps using Google's Flutter rendering engine โ€” without writing Dart, HTML, or JavaScript. You write pure Python; Flet translates your code into Flutter widgets that run as a native desktop window, a mobile app, or a web page in the browser.

Flet was created by Appveyor Systems and targets developers who want modern Material Design UIs with minimal front-end knowledge. It is one of the fastest ways to ship a Python app that also runs in a browser.

Architecture & Core Concepts

  • Page โ€” the root container passed to your main(page) function.
  • Controls โ€” ft.Text, ft.ElevatedButton, ft.TextField, ft.Column, etc.
  • Explicit updates โ€” after changing control properties, call page.update().
  • Layouts โ€” Row, Column, Stack, Container with alignment and spacing.
  • Routing โ€” page.views and page.go() for multi-page navigation.
  • Deployment modes โ€” desktop app, web app (ft.app(view=ft.WEB_BROWSER)), or mobile.

Common controls

ControlPurpose
TextFieldText input
ElevatedButton / OutlinedButtonActions
Checkbox / Switch / SliderBoolean and numeric input
DropdownSelection from list
DataTableTabular data
NavigationRail / AppBarApp chrome

Installation

shell
pip install flet

# Run as desktop app (default):
python main.py

# Run in browser:
# ft.app(target=main, view=ft.WEB_BROWSER)

Example 1 โ€” Counter

python
import flet as ft

def main(page: ft.Page):
    page.title = "Flet demo"
    txt = ft.Text("0", size=30)
    def add(e):
        txt.value = str(int(txt.value) + 1)
        page.update()
    page.add(txt, ft.ElevatedButton("Add", on_click=add))

ft.app(target=main)

Example 2 โ€” Form with layout

python
import flet as ft

def main(page: ft.Page):
    page.title = "Login"
    page.padding = 30
    user = ft.TextField(label="Username")
    pwd  = ft.TextField(label="Password", password=True)
    result = ft.Text()
    def submit(e):
        result.value = f"Hello, {user.value}"
        page.update()
    page.add(
        ft.Column([
            user, pwd,
            ft.ElevatedButton("Sign in", on_click=submit),
            result
        ], spacing=12)
    )

ft.app(target=main)

Example 3 โ€” Run as web app

python
import flet as ft

def main(page: ft.Page):
    page.add(ft.Text("Running in your browser!", size=24))

# Opens at http://localhost:8550
ft.app(target=main, view=ft.WEB_BROWSER, port=8550)

Practical advice

  • Always call page.update() after modifying controls โ€” Flet does not auto-refresh.
  • Use page.theme_mode = ft.ThemeMode.DARK for dark mode.
  • Deploy web apps with flet publish or host the Flet server behind a reverse proxy.
  • Expect larger bundle sizes due to the Flutter runtime (~30โ€“80 MB).
  • Flet is evolving quickly โ€” pin versions in production (flet==x.y.z).

Real-world use cases

  • Internal tools that must run on desktop and in the browser
  • Prototypes and MVPs with Material Design polish
  • Mobile apps without learning Flutter/Dart
  • Admin panels and configuration dashboards
  • Data entry apps for teams already using Python

โœ“ Strengths

  • One codebase: web, desktop, mobile
  • Modern Material UI
  • No JS/HTML needed
  • Rapid development cycle

โœ— Weaknesses

  • Newer, evolving API
  • Heavier runtime (Flutter)
  • Less low-level control than Qt
  • Custom-drawn look, not OS-native
Use it when

You want a modern cross-platform app (including web) from a single Python codebase without front-end skills. Compare with Kivy for mobile-first touch apps.