Skip to main content

Flet-ASP – The Flet Atomic State Pattern is a reactive state management library for Flet.

Project description

flet-asp

Flet ASP - Flet Atomic State Pattern


📖 Overview

Flet ASP (Flet Atomic State Pattern) is a reactive state management library for Flet, bringing atom-based architecture and separation of concerns into Python apps — inspired by Flutter's Riverpod and ASP.

It provides predictable, testable, and declarative state through:

  • Atom – single reactive unit of state
  • Selector – derived/computed state
  • Action – handles async workflows like login, fetch, etc.

📦 Installation

Install using your package manager of choice:

Pip

pip install flet-asp

Poetry

poetry add flet-asp

UV

uv add flet-asp

📦 Features

✅ Reactive atoms (with controlled mutation)
✅ Selector (sync & async derived values)
✅ Async-safe Actions
✅ One-way and two-way binding (form inputs)
✅ Lightweight and framework-agnostic
✅ Built for Flet


🧪 Example 1 – Basic Counter

import flet as ft
import flet-asp as fa


def main(page: ft.Page):
    state = fa.get_state_manager(page)
    state.atom("count", 0)

    count_ref = ft.Ref[ft.Text]()

    def increment(e):
        state.set("count", state.get("count") + 1)

    page.add(
        ft.Text(ref=count_ref),
        ft.ElevatedButton("Increment", on_click=increment)
    )

    state.bind("count", count_ref)


if __name__ == "__main__":
    ft.app(target=main)

🧪 Example 2 – Basic counter using state alias

import flet as ft
import flet-asp as fa


def main(page: ft.Page):
    fa.get_state_manager(page)
    page.state.atom("count", 0)

    count_ref = ft.Ref[ft.Text]()

    def increment(e):
        page.state.set("count", page.state.get("count") + 1)

    page.add(
        ft.Text(ref=count_ref),
        ft.ElevatedButton("Increment", on_click=increment)
    )

    page.state.bind("count", count_ref)


if __name__ == "__main__":
    ft.app(target=main)

📁 Examples Included

Explore the examples/ folder for full apps:


🧩 Design System Ready

atomic_design

Flet-ASP also allows you to create applications following the Atomic Design System, just like Flutter.

Atomic Layer How Flet-ASP Helps
Atoms Simple reactive values (e.g., atom("email"), atom("count"), atom("message"), atom("loading")
Selectors Derived state (e.g., @selector("full_name"), @selector("total_price") or Selector(...))
Actions Encapsulate side effects (API, auth)
Bindings bind(), bind_two_way() for full UI ↔ state reactivity
Molecules/Organisms Combine logic in components
Templates Reuse UIs across screens

Learn more:


🌐 Community

Join the community to contribute or get help:

  1. Discord
  2. Report an issue

⭐ Support

If you like this project, please give it a GitHub star and stay tuned for future updates!

🤝🏽 Contributing

Contributions and feedback are welcome!

🔧 How to contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with a detailed explanation of your changes.

💬 How to give feedback:

We value your opinion! Feel free to share suggestions, ideas, or constructive criticism to help improve the project.

  1. Open an issue.
  2. Describe the problem or suggestion clearly
  3. Optionally propose a solution

🕓 Waiting for help?

Be patient — or reach out to the community on Discord for quicker responses.


Commit your work to the LORD, and your plans will succeed. Proverbs 16: 3

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

flet_asp-0.1.3.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

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

flet_asp-0.1.3-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file flet_asp-0.1.3.tar.gz.

File metadata

  • Download URL: flet_asp-0.1.3.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.1

File hashes

Hashes for flet_asp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 41dcaf5d5617eb7030e541a98fc1a8bf740ab2b8237aaa2fb638ea6bc2e9f4a3
MD5 e3ade4b22fdbefb72b6b56fea921dbba
BLAKE2b-256 87dd9e00215672124cc3ef396f382680aef179d89bc60ef6526ac06550864811

See more details on using hashes here.

File details

Details for the file flet_asp-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flet_asp-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.1

File hashes

Hashes for flet_asp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1b3b372354a8205b24448d259d9d749f90448381226547acda4025d7556d0c16
MD5 2e03c84b454e7d5d9b9b3a409b954f1b
BLAKE2b-256 bd727c2c9d98db88693ee3369b6e4257e69ccf75f70ac7202ea24e1a9265b0fc

See more details on using hashes here.

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