smart_api_executor 0.0.1
smart_api_executor: ^0.0.1 copied to clipboard
A lightweight API lifecycle executor for Dart and Flutter applications. Simplifies loading, success, failure and no-internet handling.
smart_api_executor
Lightweight • Reusable • Architecture Independent • Dart & Flutter
🚀 Overview #
smart_api_executor is a lightweight and reusable
API lifecycle execution utility for Dart and Flutter applications.
It standardizes:
- Loading state handling
- Success responses
- Failure handling
- No-internet detection
Without forcing any specific architecture or state management.
No more repeated try-catch boilerplate across projects.
✨ Features #
- ✅ Standardized API execution flow
- 🌐 Optional no-internet detection
- ⚡ Minimal boilerplate
- 🧱 Works with BLoC, Riverpod, Provider, GetX
- 🧪 Fully testable
- 🎯 Pure Dart (no UI dependency)
- 📦 Lightweight and production-ready
📱 Platform Support #
| Platform | Supported |
|---|---|
| Android | ✅ |
| iOS | ✅ |
| Web | ✅ |
| Windows | ✅ |
| macOS | ✅ |
| Linux | ✅ |
📦 Installation #
Add this to your pubspec.yaml:
dependencies:
smart_api_executor: ^0.0.1
Then run:
dart pub get
🧠 Basic Usage #
import 'package:smart_api_executor/smart_api_executor.dart';
final result = await ApiExecutor.execute(
action: () async {
return "Hello World";
},
);
if (result.status == ApiStatus.success) {
print(result.data);
} else {
print(result.error);
}
🌐 No-Internet Handling #
final result = await ApiExecutor.execute(
action: () async {
throw Exception("No Internet");
},
isNoInternet: (error) =>
error.toString().contains("No Internet"),
);
if (result.status == ApiStatus.noInternet) {
print("No connection available");
}
🔥 Example with BLoC #
emit(state.copyWith(status: DashboardStatus.loading));
final result = await ApiExecutor.execute(
action: () => repository.getDashboard(),
);
switch (result.status) {
case ApiStatus.success:
emit(state.copyWith(
status: DashboardStatus.success,
data: result.data,
));
break;
case ApiStatus.failure:
case ApiStatus.noInternet:
emit(state.copyWith(
status: DashboardStatus.failure,
error: result.error,
));
break;
default:
break;
}
📄 License #
MIT License © 2026 Yesu Balan