Flutter, but in Python
Project description
Flut
Flutter, but in Python
Overview
Flut is a Python project that exposes Flutter to Python's ecosystem. Flut is designed to honestly expose Flutter's API as closely as possible.
True Flutter
Flutter code maps almost 1:1 from Dart to Python.
// Flutter (Dart)
Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: Text('Hello'),
)
# Flut (Python)
Container(
padding=EdgeInsets.all(16),
decoration=BoxDecoration(
color=Colors.blue,
borderRadius=BorderRadius.circular(8),
),
child=Text('Hello'),
)
Under the hood, the real Flutter widget system is used.
State-of-the-Art asyncio Integration
Flut provides a true async integration, bridging asyncio with the Flutter UI thread in a design that exactly matches Flutter. Thread safety and event loop conflicts are handled internally.
No Performance Surprises
The majority of projects using Flut will enjoy near identical performance to Flutter. FFI between Python and Dart does bring additional communication overhead, but the cost is fixed.
Status
This project is in Technical Preview.
- APIs are subject to change.
- Not ready for production use.
Installation
pip install flut
Prebuilt wheels are available for Windows (x64), macOS (x64, arm64), and Linux (x64).
Building from source is also supported and requires the Flutter SDK.
Usage
Create a file app.py:
from flut import run_app
from flut.flutter.widgets import StatelessWidget, StatefulWidget, State, Text, Center, Column, Icon, MainAxisAlignment
from flut.flutter.material import MaterialApp, Scaffold, AppBar, FloatingActionButton, Icons, ThemeData, ColorScheme, Colors, Theme
class MyApp(StatelessWidget):
def build(self, context):
return MaterialApp(
title="Flut Demo",
theme=ThemeData(
colorScheme=ColorScheme.fromSeed(seedColor=Colors.deepPurple),
),
home=MyHomePage(title="Flut Demo Home Page"),
)
class MyHomePage(StatefulWidget):
def __init__(self, title):
super().__init__()
self.title = title
def createState(self):
return _MyHomePageState()
class _MyHomePageState(State[MyHomePage]):
def initState(self):
self._counter = 0
def _incrementCounter(self):
def _update():
self._counter += 1
self.setState(_update)
def build(self, context):
return Scaffold(
appBar=AppBar(
title=Text(self.widget.title),
backgroundColor=Theme.of(context).colorScheme.inversePrimary,
),
body=Center(
child=Column(
mainAxisAlignment=MainAxisAlignment.center,
children=[
Text("You have pushed the button this many times:"),
Text(
f"{self._counter}",
style=Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton=FloatingActionButton(
onPressed=self._incrementCounter,
tooltip="Increment",
child=Icon(Icons.add),
),
)
if __name__ == "__main__":
run_app(MyApp())
Run it:
python app.py
For async support:
import asyncio
from flut import run_app_async
# ... your app code ...
if __name__ == "__main__":
asyncio.run(run_app_async(MyApp()))
Flutter Parity
Flut is a project that brings Flutter to Python. Some features are not applicable in this context: whether due to platform limitations, overlap with Python's own ecosystem, being tied to the Dart development workflow, or simply due to its challanging nature. The following are out of scope, listed from lowest to highest priority for future consideration:
- Web Support
- Mobile Support
- Plugins
- Flutter DevTools
- Hot Reload
- Isolates
- Platform Channels
- Streams/StreamBuilder
- Non-State Mixins
The following are implemented with compromises:
- InheritedWidget Uses
visitAncestorElements+dependOnInheritedElementinstead of type-based lookup, resulting in O(depth) lookup vs Flutter's O(1). Negligible for typical widget trees. - Shortcuts / Actions O(depth) action lookup vs Flutter's O(1). Negligible for typical widget trees.
- showDialog wraps the builder in a StatelessWidget proxy so the dialog's widget tree is built through the standard Dart-initiated build path, enabling callbacks in dialog children to work correctly.
Build
cd flut/.flutter
flutter build windows/macos/linux --no-tree-shake-icons
License
MIT
Disclaimer
Flut is an independent project and is not endorsed by, sponsored by, or affiliated with Google LLC. Flutter is a trademark of Google LLC.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flut-0.0.2.tar.gz.
File metadata
- Download URL: flut-0.0.2.tar.gz
- Upload date:
- Size: 559.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f9b3cc11dee28d06f7537bb20b51645b71dac859f9bb93362d494d1f53cfb70
|
|
| MD5 |
5002068b51dccb25aee1324acd29a8be
|
|
| BLAKE2b-256 |
3aadc96f14844503eb795e86f2ef58c42437b4ef07c43d4b920661fb64c79e75
|
Provenance
The following attestation bundles were made for flut-0.0.2.tar.gz:
Publisher:
publish.yml on yangyuan/flut
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flut-0.0.2.tar.gz -
Subject digest:
7f9b3cc11dee28d06f7537bb20b51645b71dac859f9bb93362d494d1f53cfb70 - Sigstore transparency entry: 1260137928
- Sigstore integration time:
-
Permalink:
yangyuan/flut@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flut-0.0.2-py3-none-win_amd64.whl.
File metadata
- Download URL: flut-0.0.2-py3-none-win_amd64.whl
- Upload date:
- Size: 13.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92b3f9b429a2d9f6524eac5d552627d66df275089896c3080b61722266aa7987
|
|
| MD5 |
b819d3d8ee69bebddf409fabd3b12806
|
|
| BLAKE2b-256 |
43cd7cc7384646086639c35155bf5747d2ef6882176f2ad0c8644e4e8f2ec3e4
|
Provenance
The following attestation bundles were made for flut-0.0.2-py3-none-win_amd64.whl:
Publisher:
publish.yml on yangyuan/flut
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flut-0.0.2-py3-none-win_amd64.whl -
Subject digest:
92b3f9b429a2d9f6524eac5d552627d66df275089896c3080b61722266aa7987 - Sigstore transparency entry: 1260138201
- Sigstore integration time:
-
Permalink:
yangyuan/flut@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flut-0.0.2-py3-none-manylinux1_x86_64.whl.
File metadata
- Download URL: flut-0.0.2-py3-none-manylinux1_x86_64.whl
- Upload date:
- Size: 19.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80c007d6da20d34175b6233be06eaca50ca94eac1cd91ce15e7ccec1525dac99
|
|
| MD5 |
df641e97173349cf3cb94c7eda76e6d7
|
|
| BLAKE2b-256 |
15377c2d4d5c57ed716898868126ceec1e61f47e2184deda93693bce9f8708c7
|
Provenance
The following attestation bundles were made for flut-0.0.2-py3-none-manylinux1_x86_64.whl:
Publisher:
publish.yml on yangyuan/flut
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flut-0.0.2-py3-none-manylinux1_x86_64.whl -
Subject digest:
80c007d6da20d34175b6233be06eaca50ca94eac1cd91ce15e7ccec1525dac99 - Sigstore transparency entry: 1260138023
- Sigstore integration time:
-
Permalink:
yangyuan/flut@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flut-0.0.2-py3-none-macosx_10_14_universal2.whl.
File metadata
- Download URL: flut-0.0.2-py3-none-macosx_10_14_universal2.whl
- Upload date:
- Size: 57.0 MB
- Tags: Python 3, macOS 10.14+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccee3a11427cf6205e901c3ba862f348405f765c1f6de6e90d5d3fd74554c23e
|
|
| MD5 |
53ee84f85c37054425a6f855bddb9256
|
|
| BLAKE2b-256 |
3b4131d607e91796bdc36a0a1d994ddecbc1d3e8ee7fb560c7eb4123f53521da
|
Provenance
The following attestation bundles were made for flut-0.0.2-py3-none-macosx_10_14_universal2.whl:
Publisher:
publish.yml on yangyuan/flut
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flut-0.0.2-py3-none-macosx_10_14_universal2.whl -
Subject digest:
ccee3a11427cf6205e901c3ba862f348405f765c1f6de6e90d5d3fd74554c23e - Sigstore transparency entry: 1260138114
- Sigstore integration time:
-
Permalink:
yangyuan/flut@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/yangyuan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08bdd97b29ea370a6a2e96192a30df64ba485eff -
Trigger Event:
workflow_dispatch
-
Statement type: