smart_executer 1.3.0
smart_executer: ^1.3.0 copied to clipboard
A powerful Flutter package for executing async operations with built-in error handling, loading dialogs, retry logic, and Result pattern support.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.3.0 - 2024-01-01 #
Added #
-
Status Cards Customization: Full widget customization support
titleWidget- Custom widget for title (overridestitletext)bodyWidget- Custom widget for body (overridesmessagetext)actionsWidget- Custom widget for actions (overridesaction/secondaryAction)iconWidget- Custom widget for icon (overridesicon)showCloseButton- Option to show/hide close buttononClose- Callback when close button is pressedcloseButtonColor- Custom close button color
-
SmartLoadingCard Customization:
titleWidget- Custom title widgetbodyWidget- Custom body widgetindicatorWidget- Custom loading indicator widgetshowCloseButton- Close button support
Changed #
- Enhanced example app with custom widget demonstrations
- Status cards now support both text-based and widget-based content
1.2.0 - 2024-01-01 #
Added #
-
Status Cards: Ready-to-use cards for displaying different states in the UI
SmartErrorCard- Error state card withfromException()factorySmartSuccessCard- Success state cardSmartWarningCard- Warning state cardSmartInfoCard- Information state cardSmartEmptyCard- Empty/no data state cardSmartLoadingCard- Loading state card with progress indicator
-
Pre-configured Status Cards:
SmartOfflineCard- No internet connection cardSmartSessionExpiredCard- Session expired cardSmartTimeoutCard- Request timeout cardSmartServerErrorCard- Server error with contact support optionSmartMaintenanceCard- Under maintenance cardSmartPermissionDeniedCard- Permission required cardSmartNotFoundCard- Resource not found (404) card
-
Enhanced Example App:
- Bottom navigation with 4 screens
- Basic Usage page with all core features
- Status Cards page showcasing all card types
- Loading Dialogs page with interactive demos
- Exception Handling page with error simulation
Changed #
- Improved example app structure with multiple screens
- Added metadata demonstration in example
1.1.0 - 2024-01-01 #
Added #
-
Exception Metadata Support: Attach debugging information to exceptions
- New
ExceptionMetadataclass with fields:operationName- Name of the failed operationendpoint- API endpoint (auto-extracted from Dio)requestMethod- HTTP method (auto-extracted from Dio)userId- User identifier for trackingsessionId- Session identifiertimestamp- When the error occurredextra- Custom key-value data
- All
SmartExceptionsubclasses now includemetadatafield withMetadata()method to attach metadata to existing exceptionstoMap()method for easy serialization/logging
- New
-
ExecuterOptions Metadata Fields:
operationName- Name the operation for debuggingmetadata- Attach custom data to exceptions
-
Auto-extraction from Dio: Endpoint and HTTP method are automatically extracted from
DioException
Changed #
ExceptionMapper.fromDioException()now accepts optional metadataExceptionMapper.fromException()now accepts optional metadata- Logging now includes metadata when
enableLoggingis true
1.0.0 - 2024-01-01 #
Added #
-
Result Pattern: Type-safe
Result<T>withSuccessandFailuresealed classesmap(),flatMap(),fold()for functional programming stylegetOrElse(),getOrCompute()for default valuesonSuccess(),onFailure()for side effects
-
SmartExecuter Core Methods:
execute<T>()- ReturnsResult<T>without UIrun<T>()- Executes with loading dialoginBackground<T>()- Executes without UI feedbackrunStream<T>()- Stream execution with progress dialoginBackgroundStream<T>()- Silent stream execution
-
Global Configuration (
SmartExecuterConfig):- Custom loading dialog builder
- Custom error snack bar builder
- Global error handler
- Session expiration handler
- Customizable messages (error, no connection, session expired)
- Retry configuration (max retries, delay)
- Connection checking by default option
- Logging toggle
-
Per-Operation Options (
ExecuterOptions):- Show/hide loading dialog
- Check connection before request
- Override retry settings
- Custom timeout
- Custom loading widget
- Barrier dismissible option
- Custom barrier color
-
Exception Hierarchy (sealed classes):
SmartException- Base exceptionConnectionException- No internet connectionConnectionTimeoutException- Connection timeoutSendTimeoutException- Request send timeoutReceiveTimeoutException- Response receive timeoutCancelledException- Request cancelledResponseException- Server error (with status code)SessionExpiredException- 401 UnauthorizedUnknownException- Unknown errorsExceptionMapper- Converts Dio exceptions to SmartExceptions
-
Loading Dialogs:
SmartLoadingDialog- Customizable circular progress dialogSmartProgressDialog- Linear progress with percentageSmartLoadingOverlay- Minimal fullscreen overlay
-
Snack Bars:
SmartErrorSnackBar- Error display with auto-coloringSmartSuccessSnackBar- Success message displaySmartSnackBars- Helper class for showing snack bars
-
Connectivity Utilities (
ConnectivityChecker):hasConnection()- Check if connectedgetStatus()- Get connection typesisConnectedViaWifi()- WiFi checkisConnectedViaMobile()- Mobile data checkisConnectedViaEthernet()- Ethernet checkonConnectivityChanged- Stream of connectivity changes
-
Retry Mechanism:
- Automatic retry with exponential backoff
- Configurable max attempts and delay
- Smart retry (skips non-retryable errors)
-
CancelToken Support:
- Pass Dio
CancelTokento cancel requests - Proper handling of cancelled requests
- Pass Dio
Changed #
- Complete rewrite of the library architecture
- Modular file structure under
lib/src/ - Improved error handling with sealed classes
- Removed dependency on external
ErrorInfoBarandAppWaitingDialog - All widgets now included in the package
Removed #
- Deprecated
while(true)busy-wait loops - Hard-coded Arabic strings (now configurable)
- External widget dependencies