zeba_academy_state_tools 1.0.0 copy "zeba_academy_state_tools: ^1.0.0" to clipboard
zeba_academy_state_tools: ^1.0.0 copied to clipboard

Lightweight reactive state management toolkit for Flutter with async state widgets, reactive controllers, lifecycle-aware state handling and minimal boilerplate.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:zeba_academy_state_tools/zeba_academy_state_tools.dart';

void main() {
  runApp(const StateToolsExampleApp());
}

class StateToolsExampleApp extends StatelessWidget {
  const StateToolsExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: "Zeba Academy State Tools",
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: Colors.indigo,
      ),
      home: const DemoPage(),
    );
  }
}

class CounterController extends ReactiveController<int> {
  CounterController() : super(0);

  void increment() {
    state = state + 1;
  }
}

class DataController extends AsyncController<String> {
  Future<void> loadData() async {
    await run(() async {
      await Future.delayed(const Duration(seconds: 2));
      return "Data loaded successfully 🚀";
    });
  }
}

class DemoPage extends StatefulWidget {
  const DemoPage({super.key});

  @override
  State<DemoPage> createState() => _DemoPageState();
}

class _DemoPageState extends State<DemoPage> {

  final counterController = CounterController();
  final dataController = DataController();

  @override
  void initState() {
    super.initState();
    dataController.loadData();
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: const Text("Zeba Academy State Tools"),
        centerTitle: true,
      ),
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: ListView(
          children: [

            const Text(
              "State Management Toolkit Demo",
              style: TextStyle(
                fontSize: 22,
                fontWeight: FontWeight.bold,
              ),
            ),

            const SizedBox(height: 25),

            /// Reactive Controller Card
            Card(
              elevation: 4,
              child: Padding(
                padding: const EdgeInsets.all(20),
                child: Column(
                  children: [

                    const Row(
                      children: [
                        Icon(Icons.flash_on, size: 28),
                        SizedBox(width: 10),
                        Text(
                          "Reactive Controller",
                          style: TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.bold,
                          ),
                        )
                      ],
                    ),

                    const SizedBox(height: 20),

                    StateBuilder<int>(
                      controller: counterController,
                      builder: (context, state) {
                        return Text(
                          "Counter: $state",
                          style: const TextStyle(
                            fontSize: 28,
                            fontWeight: FontWeight.bold,
                          ),
                        );
                      },
                    ),

                    const SizedBox(height: 20),

                    ElevatedButton.icon(
                      onPressed: counterController.increment,
                      icon: const Icon(Icons.add),
                      label: const Text("Increment Counter"),
                    )

                  ],
                ),
              ),
            ),

            const SizedBox(height: 25),

            /// Async State Card
            Card(
              elevation: 4,
              child: Padding(
                padding: const EdgeInsets.all(20),
                child: Column(
                  children: [

                    const Row(
                      children: [
                        Icon(Icons.cloud_download, size: 28),
                        SizedBox(width: 10),
                        Text(
                          "Async State Widget",
                          style: TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.bold,
                          ),
                        )
                      ],
                    ),

                    const SizedBox(height: 20),

                    AnimatedBuilder(
                      animation: dataController,
                      builder: (context, _) {
                        return AsyncStateWidget<String>(
                          state: dataController.state,
                          builder: (data) {
                            return Text(
                              data,
                              style: const TextStyle(
                                fontSize: 20,
                                fontWeight: FontWeight.w500,
                              ),
                            );
                          },
                        );
                      },
                    )

                  ],
                ),
              ),
            ),

            const SizedBox(height: 30),

            const Text(
              "Powered by zeba_academy_state_tools",
              textAlign: TextAlign.center,
              style: TextStyle(color: Colors.grey),
            )

          ],
        ),
      ),
    );
  }
}
0
likes
140
points
100
downloads
screenshot

Documentation

API reference

Publisher

verified publisherzeba.academy

Weekly Downloads

Lightweight reactive state management toolkit for Flutter with async state widgets, reactive controllers, lifecycle-aware state handling and minimal boilerplate.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on zeba_academy_state_tools