-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Description:
Currently, when working with FletXPage, developers need to access ft.page directly for common actions like showing a loader, a snackbar, or a dialog.
This can slow down development and make code less clean.
Proposed Solution:
Add built-in utility methods to FletXPage that act as shortcuts for these actions:
-
self.show_loader(message: str, widget: Optional[Control] = None)- Displays a popup with a loading message and a
ProgressRingby default. - Allows passing a custom widget for flexibility.
- Displays a popup with a loading message and a
-
self.show_snackbar(message: str, duration: int = 3000, widget: Optional[Control] = None)- Displays a snackbar directly from a
FletXPage. - Allows passing a custom widget for flexibility.
- Displays a snackbar directly from a
-
self.show_dialog(dialog: Control)- Opens dialog boxes without needing to call
ft.pagemanually.
- Opens dialog boxes without needing to call
Example Usage:
class MyPage(FletXPage):
...
def on_load(self):
self.show_loader("Loading data...")
# simulate some work...
self.show_snackbar("Data loaded successfully")
def on_error(self):
self.show_dialog(
AlertDialog(title=Text("An error occurred"), on_dismiss=self.close_dialog)
)
...Benefits:
- Speeds up development.
- Makes code cleaner and more readable.
- Improves developer experience by reducing boilerplate code.
Metadata
Metadata
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers