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
ProgressRing by default.
- Allows passing a custom widget for flexibility.
-
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.
-
self.show_dialog(dialog: Control)
- Opens dialog boxes without needing to call
ft.page manually.
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.
Description:
Currently, when working with
FletXPage, developers need to accessft.pagedirectly 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
FletXPagethat act as shortcuts for these actions:self.show_loader(message: str, widget: Optional[Control] = None)ProgressRingby default.self.show_snackbar(message: str, duration: int = 3000, widget: Optional[Control] = None)FletXPage.self.show_dialog(dialog: Control)ft.pagemanually.Example Usage:
Benefits: