data_handler 0.0.3
data_handler: ^0.0.3 copied to clipboard
Handle Data Manage State With GetX and State Management
DataHandler πβ¨π¦ #
Effortless State Management for API Responses in Flutter Apps! π―π±β‘
DataHandler
is a lightweight and efficient state management utility designed to handle API responses seamlessly across all Flutter platforms (Android, iOS, Web, Windows, macOS, and Linux). It simplifies state handling, including loading, success, error, and empty states, ensuring a smooth UI experience. ππ
π Features #
β
Universal Compatibility β Works across all platforms!
β
Easy API Response Management β Handle different states effortlessly.
β
Built-in State Handlers β Loading, Success, Error, and Empty states.
β
Flexible UI Rendering β Provides dynamic builders for widgets and lists.
β
Works with Any Data Type (T
) β Highly versatile and reusable.
β
Minimal Setup, Maximum Productivity β Get started in seconds!
π₯ Installation #
Add DataHandler
to your pubspec.yaml
:
dependencies:
data_handler: latest_version # Replace with the latest version
Then, run:
flutter pub get
π Quick Start #
1οΈβ£ Import the Package #
import 'package:data_handler/data_handler.dart';
2οΈβ£ Initialize DataHandler #
final handler = DataHandler<String>();
3οΈβ£ Manage API States #
π Loading State
handler.startLoading();
β Success State
handler.onSuccess("Data loaded successfully");
β Error State
handler.onError("Something went wrong");
π Empty State
handler.onEmpty("No data available");
π₯οΈ UI Integration #
π Handle Different States Dynamically #
Widget build(BuildContext context) {
return handler.when(
context: context,
loadingBuilder: (ctx) => CircularProgressIndicator(),
successBuilder: (data) => Text(data),
errorBuilder: (error) => Text("Error: $error"),
emptyBuilder: (message) => Text("No Data: $message"),
);
}
π List Handling (Ideal for Fetching Lists) #
List<Widget> buildList(BuildContext context) {
return handler.whenListWidget(
context: context,
loadingBuilder: (ctx) => [CircularProgressIndicator()],
successBuilder: (data) => [Text("Item: $data")],
errorBuilder: (error) => [Text("Error: $error")],
emptyBuilder: (message) => [Text("No items found")],
);
}
πΊ Preview #
Here's a preview of how DataHandler
works in a real Flutter app:
π Cross-Platform Compatibility #
DataHandler
is fully optimized for Flutterβs multi-platform capabilities, ensuring smooth performance on:
π± Android | π iOS | π₯οΈ Web | π’ Windows | π macOS | π§ Linux
β
β
β
β
β
β
π€ Contributing #
We love contributions! π
Feel free to open issues, discuss features, or submit pull requests to enhance DataHandler
. Letβs build something amazing together! π οΈβ¨
π License #
This package is released under the MIT License. π
Enjoy using DataHandler
? Give it a β on GitHub! ππ