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.0a11.tar.gz (401.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.0a11-py3-none-win_amd64.whl (11.6 MB view details)

Uploaded Python 3Windows x86-64

flut-0.0.0a11-py3-none-manylinux1_x86_64.whl (18.7 MB view details)

Uploaded Python 3

flut-0.0.0a11-py3-none-macosx_10_14_universal2.whl (51.4 MB view details)

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

File details

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

File metadata

  • Download URL: flut-0.0.0a11.tar.gz
  • Upload date:
  • Size: 401.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.0a11.tar.gz
Algorithm Hash digest
SHA256 cc19c8bb0c2164b7a17b755adf7894b1c1df4553bef292fa2e135c17c05f59a9
MD5 e52f40c71f290bdfcfb746ba7fda5594
BLAKE2b-256 04fc27263f39255b7846af5020029108cae812031396f1c21dcaa71e01915346

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: flut-0.0.0a11-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.6 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.0a11-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d350f88c19c2c12df7b615a6c5fd32b41ed74b7bdce1b095b078f2294e005eed
MD5 b57882359cce38c40c0befaf1f2e07b6
BLAKE2b-256 22623178663a41313d0abe2022cb2f0f082aff1b795c4c7bd7ff4d36795f7860

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for flut-0.0.0a11-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cd0d69a1bd187f8b1a64884d2c6f06565abccf7d1e07d687047d84b7e5731d44
MD5 3076002d1740f74bd05794748995bea9
BLAKE2b-256 c5a5caab76f459cfc2a175e22c6d2b482b721da47049d9dd9ad08c01ca1148cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for flut-0.0.0a11-py3-none-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 27d131e3ab2c264ab0c3b5c84a09416b0de0da1f193315f997132d40e058c39f
MD5 8a6834d470fd57c846a13073ee1450b1
BLAKE2b-256 0539686887e12158b12e9ac0f0b71db28484f89ecdad38abd402d8c3c7f41895

See more details on using hashes here.

Provenance

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