Skip to main content

FletX is a powerful routing and state management library for the Flet framework. It simplifies application development by separating UI and logic while providing intuitive navigation solutions.

Project description

FletX

License
Platform
Version

FletX is a powerful routing and state management library for the Flet framework. It simplifies application development by separating UI and logic while providing intuitive navigation solutions.


✨ Features

  • Seamless Routing: Effortless and dynamic navigation management.
  • State Management: Manage complex states with ease.
  • Logic-UI Separation: Keep your code clean and maintainable.
  • Lightweight and Fast: Designed for performance.

📦 Installation

Add the FletX package to your project:

pip install fletx

🚀 Getting Started

🌟 Statefull Counter App Example

Directory & File Structure

📦CounterApp
    ├── main.py
    ├── states
       └── main_state.py
    └── views
        ├── counter_view.py
        └── home_view.py

main.py

import flet as ft
from fletx import Xapp,route
from states.main_state import MainState
from views.home_view import HomeView
from views.counter_view import CounterView

def main(page: ft.Page):
    page.title = "FletX counter example"

    Xapp(
        page=page,
        init_route="/",
        state=MainState,
        routes=[
            route(route="/",view=HomeView),
            route(route="/counter",view=CounterView),
        ]
    )

ft.app(main)

states/main_state.py

import flet as ft
from fletx import Xstate

class MainState(Xstate):
    def __init__(self, page):
        super().__init__(page)
        
        self.txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(self,e):
        self.txt_number.value = str(int(self.txt_number.value) - 1)
        self.update()

    def plus_click(self,e):
        self.txt_number.value = str(int(self.txt_number.value) + 1)
        self.update()

views/home_view.py

import flet as ft 
from fletx import Xview

class HomeView(Xview):

    def build(self):
        return ft.View(
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
            vertical_alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.Text("Home View"),
                ft.Text(f"Counts = {self.state.txt_number.value}"),
                ft.ElevatedButton("Go Counter View",on_click=lambda e:self.page.go("/counter"))
            ]
        )

views/counter_view.py

import flet as ft 
from fletx import Xview

class CounterView(Xview):

    def build(self):
        return ft.View(
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
            vertical_alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.Row(
                    [
                        ft.IconButton(ft.Icons.REMOVE, on_click=self.state.minus_click),
                        self.state.txt_number,
                        ft.IconButton(ft.Icons.ADD, on_click=self.state.plus_click),
                    ],
                    alignment=ft.MainAxisAlignment.CENTER,
                ),
                ft.ElevatedButton("<< Back",on_click=self.back)
            ]
        )

❤️ Feedback

Found this example helpful? Let us know!

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

fletx-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

fletx-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file fletx-0.1.0.tar.gz.

File metadata

  • Download URL: fletx-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for fletx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b0c885a141ee6a4efc0375cb94ccb056f7fa1b0989eb03d239d1974985c2341
MD5 3f172404ec7ea6158919019e2c8198ce
BLAKE2b-256 ffb00fe60cf68ebfa5f6b729b6183ea9c861ddea4c41a6bb564114e984e69ece

See more details on using hashes here.

File details

Details for the file fletx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fletx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for fletx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09ebf90c248e97b3fff2536d3f37ada61d159750fee1eda6cb52f48c85744eb9
MD5 d13d5a76b64aae8bd1c5f6f2e09c0321
BLAKE2b-256 f9399f12d089a04d7737af0adffb27e547165f35831bc0ffb15497ebf627787d

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