Overview
Flet provides two approaches for building desktop applications:flet build- Creates a Flutter-based app bundle for production distributionflet pack- Creates a PyInstaller-based executable for quick packaging
Building with flet build
The flet build command creates production-ready desktop applications using Flutter as the UI framework.
Platform Support
| Command | Can Build On |
|---|---|
flet build windows | Windows |
flet build macos | macOS |
flet build linux | Linux |
Basic Usage
build/<platform> directory.
Build Configuration
Configure your desktop app usingpyproject.toml:
pyproject.toml
Command-Line Options
Project Metadata
--project- Project name for bundle identifiers (default: directory name)--product- Display name shown in app launchers and window titles--artifact- Executable or bundle filename on disk--description- Short description of the application--company- Company name for about dialogs--org- Organization in reverse domain notation (e.g.,com.mycompany)--copyright- Copyright text for about dialogs
Build Options
--arch- Target CPU architectures (macOS:arm64,x64; Linux:arm64,x64)--build-version- Version string shown to users (e.g.,1.2.3)--build-number- Internal version number (integer)-o,--output- Custom output directory--exclude- Files/directories to exclude from the package--clear-cache- Remove existing build cache before building
Advanced Options
--compile-app- Pre-compile app’s.pyfiles to.pyc--compile-packages- Pre-compile site packages to.pyc--cleanup-packages- Remove unnecessary package files--module-name- Python module name with entry point (default:main)
macOS-Specific Options
macOS builds produce
.app bundles that can be distributed via DMG or signed for the App Store.pyproject.toml
Windows-Specific Options
Windows builds produce executables inbuild/windows/x64/runner/Release/.
pyproject.toml
Linux-Specific Options
Linux builds produce a bundle directory containing the executable and dependencies.pyproject.toml
Packaging with flet pack
The flet pack command uses PyInstaller to create standalone executables. This is faster for development but produces larger files than flet build.
Basic Usage
- Windows: Single
.exefile indist/ - macOS:
.appbundle indist/ - Linux: Single executable in
dist/
Common Options
--name,-n- Name for the executable or app bundle--icon,-i- Path to icon file (.icofor Windows,.icnsfor macOS,.pngfor Linux)--add-data- Include additional files (format:source:destination)--distpath- Output directory (default:dist)
One-Directory Bundle (Windows)
Advanced PyInstaller Options
--hidden-import- Include modules not detected by static analysis--add-binary- Include binary files (format:source:destination)--product-version- Product version for metadata--file-version- File version inn.n.n.nformat (Windows)--company-name- Company name (Windows)--copyright- Copyright string
macOS Code Signing
--bundle-id- macOS bundle identifier--codesign-identity- Code signing identity for notarization
Windows UAC Admin Privileges
Customizing App Icons
Place icon files in yourassets/ directory:
flet build.
Icon Requirements
- Windows:
.icofile with multiple resolutions (16x16, 32x32, 48x48, 256x256) - macOS:
.icnsfile with multiple resolutions - Linux:
.pngfile (512x512 recommended)
You can use online tools like iConvert Icons to generate platform-specific icon files from a single PNG image.
Including Assets
Assets are automatically included when they’re in theassets/ directory:
Build Output
After runningflet build, find your application:
Running Your App
During development, useflet run for hot reload:
Comparison: flet build vs flet pack
| Feature | flet build | flet pack |
|---|---|---|
| Technology | Flutter + embedded Python | PyInstaller |
| Build Time | Slower (first build) | Faster |
| App Size | Smaller | Larger |
| Performance | Better | Good |
| Customization | Extensive | Limited |
| Production Use | Recommended | Development/testing |
| Cross-platform icons | Automatic | Manual |
| Splash screens | Supported | Not supported |
For production applications, use
flet build for better performance and smaller bundle sizes.Next Steps
- Learn about Packaging Apps for distribution
- Explore Mobile Apps for iOS and Android
- Read about Deployment options