Skip to main content

The GetX-inspired Python Framework for Building Reactive, Cross-Platform Apps with Flet

Project description

FletX ๐Ÿš€

The open-source GetX-inspired Python Framework for Building Reactive, Cross-Platform Apps with Flet

PyPI Version Downloads License Discord

Why FletX? โœจ

FletX brings Flutter's beloved GetX patterns to Python, combining Flet's UI capabilities with:

  • โšก Reactive state management
  • ๐Ÿงญ Declarative routing
  • ๐Ÿ’‰ Dependency injection
  • ๐Ÿงฉ Modular architecture
  • ๐ŸŽจ Widget library

Perfect for building desktop, web, and mobile apps with Python at lightning speed.


Showcase

web Mobile
Desktop

Quick Start ๐Ÿ

NOTE: FletX currently supports Python >=3.10,<=3.13. Compatibility with newer versions is in progress โ€” we're actively working to expand support soon.

Installation

pip install FletXr[dev] --pre

Create project

fletx new my_project --no-install

Created project structure ๐Ÿ—๏ธ

my_project/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ controllers/     # Business logic controllers
โ”‚   โ”œโ”€โ”€ services/       # Business services and API calls
โ”‚   โ”œโ”€โ”€ models/         # Data models
โ”‚   โ”œโ”€โ”€ components/     # Reusable widgets
โ”‚   โ”œโ”€โ”€ pages/          # Application pages
โ”‚   โ””โ”€โ”€ routes.py       # App routing modules
โ”œโ”€โ”€ assets/             # Static assets (images, fonts, etc.)
โ”œโ”€โ”€ tests/              # Test files
โ”œโ”€โ”€ .python-version     # Python version
โ”œโ”€โ”€ pyproject.toml      # Python dependencies
โ”œโ”€โ”€ README.md           # Quick start README
โ””โ”€โ”€ main.py            # Application entry point

To run the project, just navigate to the project folder and run this command

fletx run --web # Will open app in a navigator
        # --desktop to open app in a desktop window
        # --android to open app on Android device
        # --ios to open app on a iOs device
        # --help for more option

Basic Usage (Counter App)

import flet as ft

from fletx.app import FletXApp
from fletx.core import (
    FletXPage, FletXController, RxInt, RxStr
)
from fletx.navigation import router_config
from fletx.widgets import Obx


class CounterController(FletXController):

    def __init__(self):
        count = RxInt(0)  # Reactive state
        super().__init__()


class CounterPage(FletXPage):
    ctrl = CounterController()
    
    def build(self):
        return ft.Column(
            controls = [
                Obx(
                    builder_fn = lambda: ft.Text(
                        value = f'{self.ctrl.count}',
                        size = 100, 
                        weight = ft.FontWeight.BOLD
                    )
                ),
                ft.ElevatedButton(
                    "Increment",
                    on_click = lambda e: self.ctrl.count.increment()  # Auto UI update
                )
            ]
        )


def main():

    # Defining route
    router_config.add_route(
        **{'path': '/', 'component': CounterPage}
    )
    app = FletXApp(
        title = "My Counter",
        initial_route = "/",
        debug = True
    ).with_window_size(400, 600).with_theme(
        ft.Theme(color_scheme_seed=ft.Colors.BLUE)
    )
    
    # Run sync
    app.run()

if __name__ == "__main__":
    main()

Core Features ๐Ÿง 

1. Reactive State Management

class SearchController(FletXController):
    """Search controller"""
    
    def __init__(self):
        self.query = RxStr("")
        self.results = RxList([])
        self.is_loading = RxBool(False)
        self.is_enabled = RxBool(True)

        super().__init__()
        
        # Configure reactives effects
        self._setup_reactive_effects()
    
    def _setup_reactive_effects(self):
        """Configure reactive effects"""
        
        # Search with debounce
        @reactive_debounce(0.5)
        @reactive_when(self.is_enabled)
        def search_handler():
            if self.query.value.strip():
                self.perform_search(self.query.value)
        
        # Listen query changes
        self.query.listen(search_handler)
        
        # Cache expensive search results
        @reactive_memo(maxsize=50)
        def expensive_search(query: str):
            # Expensive search simulation
            import time
            time.sleep(0.1)  # Simulate 
            return [f"Result {i} for '{query}'" for i in range(5)]
        
        self.expensive_search = expensive_search

        # Other actions here...

2. Smart Routing

# Define routes
from fletx.navigation import router_config, navigate

# 1. simple routing
router_config.add_routes([
    {"path": "/", "component": HomePage},
    {"path": "/settings", "component": SettingsPage}
])

# 2. Dynamic routes with parameters
router_config.add_routes([
    {
        "path": "/users/:id",
        "component": lambda route: UserDetailPage(route.params['id'])
    },
    {
        "path": "/products/*category",
        "component": lambda route: ProductsPage(route.params['category'])
    }
])
# Navigate programmatically
navigate("/users/123")

3. Dependency Injection

# Register services
FletX.put(AuthService(), tag="auth")

# Retrieve anywhere
auth_service = FletX.find(AuthService, tag="auth")

4. Reactive Widgets

FletX allows you to quickly create reactive widgets from flet Controls by using reactive widget decorators.

from fletx.decorators import (
    reactive_control, simple_reactive,
    reactive_state_machine, reactive_form,
    two_way_reactive, reactive_list, obx
    ...
)

Community & Support ๐Ÿ’ฌ


๐Ÿค Contributing

We welcome contributions from the community! Please see the CONTRIBUTING.md guide for more information.


License ๐Ÿ“œ

MIT ยฉ 2025 AllDotPy

# Happy coding! 
# Let's build amazing apps with Python ๐Ÿ

Made with โค๏ธ By AllDotPy

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

fletxr-0.1.4.tar.gz (122.2 kB view details)

Uploaded Source

Built Distribution

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

fletxr-0.1.4-py3-none-any.whl (124.2 kB view details)

Uploaded Python 3

File details

Details for the file fletxr-0.1.4.tar.gz.

File metadata

  • Download URL: fletxr-0.1.4.tar.gz
  • Upload date:
  • Size: 122.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fletxr-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7d4583c65f7bb515e099e4e0add7d8df7fdbf3b2625601a82a89641b20800af9
MD5 2c38ece102980060d59464f4153b1e7c
BLAKE2b-256 162e6e1711b76bc7b50447bf48a1b1005e1dadf71cf8b9bcc9e46500ca43cbd4

See more details on using hashes here.

File details

Details for the file fletxr-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: fletxr-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 124.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fletxr-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0a6a6c74d862fba724e42c0013c297884c1abb60ceb18328416bd04194982c7d
MD5 50df48ccdfe747fb7141d086b4deb70a
BLAKE2b-256 fb982925872f6ef29bc9023029ccd56943cfe79268adb70050cef7ca34b82ba8

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