Getting Started#
This guide walks you through creating your first Flet extension package.
Prerequisites#
- Python 3.11+
- uv (recommended) or pip
Installation#
Or with pip:
Creating your first extension#
1. Run the create command#
You'll be prompted for:
- Extension type — Auto-detect (recommended), Service (non-visual), or UI Control (visual widget)
- Flutter package name — the pub.dev package you're wrapping (e.g.
onesignal_flutter) - Extension name — auto-derived, e.g.
flet-onesignal - Python package name — auto-derived, e.g.
flet_onesignal - Control class name — auto-derived, e.g.
Onesignal - Description and Author
Auto-detect
When you choose Auto-detect, flet-pkg downloads the Flutter package and inspects the Dart source code to determine whether it contains widgets (UI Control) or only services. This is the recommended option if you're unsure which type to pick.
Name conflict detection
After you enter the extension name, flet-pkg checks PyPI, GitHub, and the official Flet SDK monorepo (flet-dev/flet) for existing packages with the same name. If matches are found, links are displayed and you can choose whether to continue.
2. Navigate to your project#
3. Install dependencies#
4. Run tests#
Name derivation#
flet-pkg automatically derives names from the Flutter package name:
| Flutter package | Project name | Python package | Class name |
|---|---|---|---|
onesignal_flutter |
flet-onesignal |
flet_onesignal |
Onesignal |
flutter_map |
flet-map |
flet_map |
Map |
google_maps_flutter |
flet-google-maps |
flet_google_maps |
GoogleMaps |
Common Flutter affixes (flutter_, _flutter, _plus, _pro) are stripped automatically.
What's next#
- Edit the Python control file in
src/<package_name>/to implement your Flet control - Review and complete the generated Dart service/widget in
src/flutter/<package_name>/lib/src/(it's a working scaffold) - Add examples in
examples/ - Run
flet-pkg --helpfor all available options
Trying out your extension#
The example app under examples/<package_name>_example/ is pre-wired to use your
extension from source. Build it to test the control:
cd examples/<package_name>_example
uv sync
flet build macos # or: windows | linux | apk | aab | ipa | web
Use flet build, not flet run
flet run launches Flet's prebuilt client, which only knows the built-in
controls — a control from a custom extension renders as "Unknown control"
(and a custom service's Dart code never runs). flet build compiles a Flutter
app that includes your extension's Dart code, so it actually works. This is the
most common point of confusion when starting out.