Skip to main content

Flutter but Python

Project description

Flut

Flutter, but in Python

Status

This project is in Technical Preview.

  • APIs are subject to change.
  • Not ready for production use.

Installation

pip install flut

That's it! Windows (x64), macOS (x64, arm64), and Linux (x64) have prebuilt wheels.

You can build from source as well, you will need the Flutter SDK installed.

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()))

Development Setup

cd flut/.flutter
flutter build windows/macos/linux --no-tree-shake-icons

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flut-0.0.0a12.tar.gz (404.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

flut-0.0.0a12-py3-none-win_amd64.whl (12.4 MB view details)

Uploaded Python 3Windows x86-64

flut-0.0.0a12-py3-none-manylinux1_x86_64.whl (18.8 MB view details)

Uploaded Python 3

flut-0.0.0a12-py3-none-macosx_10_14_universal2.whl (52.0 MB view details)

Uploaded Python 3macOS 10.14+ universal2 (ARM64, x86-64)

File details

Details for the file flut-0.0.0a12.tar.gz.

File metadata

  • Download URL: flut-0.0.0a12.tar.gz
  • Upload date:
  • Size: 404.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flut-0.0.0a12.tar.gz
Algorithm Hash digest
SHA256 9d265f8283c13e136e70c39ad924db69cc7a743b02fd22a9aeffd6476e6a6e81
MD5 4d6bf379fb99fff1eb97fcae5f3b622b
BLAKE2b-256 9e390f27e101be37859e000a41b0374d27ca1bd17fd57004ce93d63f3c55d6fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a12.tar.gz:

Publisher: publish.yml on yangyuan/flut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flut-0.0.0a12-py3-none-win_amd64.whl.

File metadata

  • Download URL: flut-0.0.0a12-py3-none-win_amd64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flut-0.0.0a12-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 429d92d346ff406e96e53aca6d0966d8404a5266f9decd66dd5da75294e52a61
MD5 37b9923e52fb12187540a9c65b66d7ef
BLAKE2b-256 62b536b4a88967fd5ddac484ae8fe6ba5578600bf7b06312dad3dc8556f68eb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a12-py3-none-win_amd64.whl:

Publisher: publish.yml on yangyuan/flut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flut-0.0.0a12-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for flut-0.0.0a12-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 eae4c4e431772df57c6d7f4718036e4c5ea9f35ed2489619550f51498bd6e778
MD5 eda8501166114976da563220d9dd1176
BLAKE2b-256 48a681036707a4e227e5aae564312c13c2c11fcac6bd12063761198cdbca78a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a12-py3-none-manylinux1_x86_64.whl:

Publisher: publish.yml on yangyuan/flut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flut-0.0.0a12-py3-none-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for flut-0.0.0a12-py3-none-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 59573bdf25f124e31cb83aa46a4badddb60371b46b711a7e417acabd196d3a50
MD5 59be440fc3eb66362e2839c9b9398414
BLAKE2b-256 9d5467a64ef0eba58d8edead3c6d54170508c1a800d9fd84c17622bf3070bbad

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a12-py3-none-macosx_10_14_universal2.whl:

Publisher: publish.yml on yangyuan/flut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page