β‘ OnProcessButtonWidget
A sleek, production-ready Flutter button widget with built-in loading states, progress indicators, and status feedback (Success/Error).
π¦ Ready for pub.flutter-io.cn! A highly customizable replacement for standard buttons that handles asynchronous operations with ease.
β¨ Features
- β³ Loading State β Built-in progress indicator, auto-disables button during execution.
- β Status Feedback β Displays Success or Error icons/widgets based on operation result.
- π¨ Deeply Customizable β Control colors, radius, borders, shadows, animations, and icons.
- π Theme Support β Global configuration via
OnProcessButtonThemeorOnProcessButtonDefaultValues. - π« Smooth Animations β Animated size transitions and status changes.
- π± Platform Ready β Supports Android, iOS, Web, macOS, Windows, and Linux.
π¦ Installation
flutter pub add on_process_button_widget
Or add manually to pubspec.yaml:
dependencies:
on_process_button_widget: ^2.0.12
π Quick Start
import 'package:on_process_button_widget/on_process_button_widget.dart';
// Basic usage β return true for success, false for error
OnProcessButtonWidget(
onTap: () async {
await Future.delayed(Duration(seconds: 2));
return true; // Shows success icon
},
child: Text('Submit'),
)
// With full customization
OnProcessButtonWidget(
backgroundColor: Colors.blue,
iconColor: Colors.white,
onTap: () async {
bool success = await myAsyncOperation();
return success;
},
onDone: (isSuccess) {
print('Operation finished with success: $isSuccess');
},
child: Text('Save Changes'),
)
ποΈ Key Properties
| Property | Type | Default | Description |
|---|---|---|---|
onTap |
Future<bool?> Function()? |
null |
Async tap handler. Return true for success, false for error. |
onDone |
Function(bool?)? |
null |
Called after onTap and status display completion. |
child |
Widget? |
null |
Primary button content. |
isRunning |
bool |
false |
Manually trigger loading state. |
backgroundColor |
Color? |
Theme primary |
Button background color. |
borderRadius |
BorderRadius? |
8.0 |
Corner radius. |
onRunningWidget |
Widget? |
CircularProgress |
Widget shown while processing. |
onSuccessWidget |
Widget? |
Icons.done |
Widget shown on success. |
onErrorWidget |
Widget? |
Icons.error |
Widget shown on error. |
expanded |
bool |
true |
Whether to take full available width. |
π¨ Global Configuration
You can set default values for all buttons in your app using OnProcessButtonDefaultValues or OnProcessButtonThemeProvider.
void main() {
// Simple property defaults
OnProcessButtonDefaultValues.backgroundColor = Colors.deepPurple;
OnProcessButtonDefaultValues.borderRadius = BorderRadius.circular(12);
OnProcessButtonDefaultValues.expandedIcon = true;
OnProcessButtonDefaultValues.roundBorderWhenRunning = false;
// Global status change listener (e.g., showing a dialog during processing)
OnProcessButtonDefaultValues.onStatusChange = (context, status) {
if (context == null) return;
if (status == OnProcessButtonStatus.running) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: Text("Processing"),
content: Text("Please wait while we handle your request..."),
),
);
} else if (status == OnProcessButtonStatus.stable) {
// Auto-close dialog when finished
Navigator.of(context).pop();
}
};
runApp(MyApp());
}
πΈ Screenshots & Demos
| All Features | Hover Effects |
|---|---|
![]() |
![]() |
| Request Status | Double Process |
![]() |
![]() |
| Custom Styles | Card Mode |
![]() |
![]() |
π License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Made with β€οΈ by Shajedur Rahman Panna





