Skip to content

flet-pkg

flet-pkg

CLI tool to scaffold Flet extension packages.

Generates complete, ready-to-develop Flet extensions with Python + Flutter/Dart code, following Flet 0.80.x+ patterns.

Important: this tool does not perform miracles. ๐Ÿ™๐Ÿ˜‚

Every Flutter package on pub.dev has its own API surface, configuration requirements, and platform-specific behaviors. Some packages expose simple method calls; others require complex initialization flows, native platform setup (Android manifests, iOS plists, Gradle/CocoaPods configuration), or callback-based architectures that don't map cleanly to Python.

It would be unrealistic to write a code generation algorithm that generalizes perfectly for every possible Flutter package. flet-pkg aims to accelerate the process by delivering significantly more than a blank skeleton โ€” it downloads the real Dart source, parses the public API, and auto-generates Python controls, type mappings, enum definitions, event handlers, and Dart bridge code. For service packages, this typically covers ~95% of the API surface.

However, the developer is still responsible for:

  • Understanding how the original Flutter/Dart package works
  • Reviewing the generated code for correctness
  • Handling package-specific configurations (native platform setup, initialization flows, etc.)
  • Adjusting or complementing the generated code for edge cases the pipeline could not cover

Think of flet-pkg as a smart starting point, not a finished product.

Features#

  • Interactive & non-interactive modes โ€” guided prompts or full CLI flags
  • Auto-detect extension type โ€” downloads the Flutter package and detects whether it's a Service or UI Control automatically
  • Three extension types โ€” Auto-detect (recommended), Service (non-visual), and UI Control (visual widget)
  • Name conflict detection โ€” checks PyPI, GitHub, and the Flet SDK monorepo before creating, warns if the name already exists
  • Complete project scaffolding โ€” Python package, Flutter package, tests, docs, examples
  • Smart name derivation โ€” automatically derives project, package, and class names from the Flutter package name
  • Flet 0.80.x+ patterns โ€” uses @ft.control, ft.Service, ft.LayoutControl, invoke_method, and EventHandler
  • AI refinement โ€” optional LLM-powered code improvement using the Architect/Editor pattern
  • MCP Server โ€” expose scaffolding and analysis tools to AI agents via the Model Context Protocol

Quick install#

pip install flet-pkg

Or with uv:

uv tool install flet-pkg

Quick start#

flet-pkg create

This walks you through creating a new Flet extension with interactive prompts.

For non-interactive usage (auto-detect type):

flet-pkg create --type auto --flutter-package onesignal_flutter --output .

Or specify the type explicitly:

flet-pkg create --type service --flutter-package onesignal_flutter --output .

With AI refinement#

uv add flet-pkg[ai]
ollama pull qwen2.5-coder:14b
flet-pkg create -f shimmer --ai-refine

Generated project structure#

flet-onesignal/
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ mkdocs.yml
โ”œโ”€โ”€ docs/
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ examples/
โ”‚   โ””โ”€โ”€ flet_onesignal_example/
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ flet_onesignal/        # Python package
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ”œโ”€โ”€ onesignal.py       # @ft.control + ft.Service
    โ”‚   โ””โ”€โ”€ types.py
    โ””โ”€โ”€ flutter/
        โ””โ”€โ”€ flet_onesignal/    # Flutter package
            โ”œโ”€โ”€ pubspec.yaml
            โ””โ”€โ”€ lib/
                โ””โ”€โ”€ src/
                    โ”œโ”€โ”€ extension.dart
                    โ””โ”€โ”€ onesignal_service.dart

Learn more#


Support the Project#

If you find this project useful, consider giving it a star on GitHub and supporting its development:

Buy Me a Coffee

GitHub ยท X ยท LinkedIn


Try flet-pkg today and turn any Flutter package into a Flet extension in seconds!#


Proverbs 16:3

Commit your work to the LORD, and your plans will succeed. Proverbs 16:3