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.0a8.tar.gz (387.5 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.0a8-py3-none-win_amd64.whl (11.5 MB view details)

Uploaded Python 3Windows x86-64

flut-0.0.0a8-py3-none-manylinux1_x86_64.whl (15.3 MB view details)

Uploaded Python 3

flut-0.0.0a8-py3-none-macosx_10_14_universal2.whl (50.7 MB view details)

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

File details

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

File metadata

  • Download URL: flut-0.0.0a8.tar.gz
  • Upload date:
  • Size: 387.5 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.0a8.tar.gz
Algorithm Hash digest
SHA256 e476bca9943615ec9d0b5740cd5075e3c6906f130ad8f8066855b6df07e0769d
MD5 2f3fde5c7d7a4c0610bea6f03fedf5bf
BLAKE2b-256 aafa58eef8014bc4b344b8833241edf42704f88de8e03f2d7a7fc7d9ad998435

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a8.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.0a8-py3-none-win_amd64.whl.

File metadata

  • Download URL: flut-0.0.0a8-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.5 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.0a8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 832c58fc12f19056a50f2a2d9283a50bbfdd896f21b5346c0d1e1c9f88e54783
MD5 715ea7db0c8fc9a89163a468fbda03c8
BLAKE2b-256 77ffa30ca50259513dca615911a1477b3ac01a5ac4d7f98a3061de5e5c11bbb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a8-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.0a8-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for flut-0.0.0a8-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c92b13932ead6f95c498c11fe8036f1a65721b38b69d0cf289d0c387bf21cf7a
MD5 b2e29976def8ce9d4c54b66a73070b1b
BLAKE2b-256 300e4a4f222ae82569d5a93a5ee29550d88355f3631a5d28dc554c1036c57b12

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a8-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.0a8-py3-none-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for flut-0.0.0a8-py3-none-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 a8da0123e02970592622ef48accbe94ea08acbd4fafa2d185dc09dd794032e1d
MD5 83209377770e50fc5352a7e284122356
BLAKE2b-256 06c97dba76c2b04960e482d18a51828c8e8605bc63d139268c28aa902ab301ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for flut-0.0.0a8-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