data_handler 0.0.2 copy "data_handler: ^0.0.2" to clipboard
data_handler: ^0.0.2 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")],
  );
}

🌍 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! πŸ˜ŠπŸš€

2
likes
0
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

Handle Data Manage State With GetX and State Management

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on data_handler