flutter_simple_usestate 0.0.1 copy "flutter_simple_usestate: ^0.0.1" to clipboard
flutter_simple_usestate: ^0.0.1 copied to clipboard

A simple and lightweight state management library.

πŸͺΆ Flutter Simple UseState #

A simple and minimal state management solution built on top of Flutter’s ValueNotifier.

This library provides a clean, hook-like API to manage state with almost zero boilerplate.


✨ Features #

  • ⚑ Extremely lightweight
  • 🧠 Built on native Flutter primitives (ValueNotifier)
  • πŸ” Reactive UI updates
  • πŸ“¦ No external dependencies
  • 🎯 Easy to learn and use

πŸš€ Getting Started #

Import the library #

import 'package:flutter_simple_usestate/flutter_simple_usestate.dart';

🧩 Usage #

1. Create state #

final counter = useState<int>(0);

2. Update state #

counter.value++;

3. Bind state to UI #

useStateBuilder<int>(
  counter,
  (value) {
    return Text('$value');
  },
);

πŸ“Œ Full Example #

import 'package:flutter/material.dart';

class CounterPage extends StatelessWidget {
  final counter = useState<int>(0);

  CounterPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Counter')),
      body: Center(
        child: useStateBuilder<int>(
          counter,
          (value) => Text(
            '$value',
            style: const TextStyle(fontSize: 24),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => counter.value++,
        child: const Icon(Icons.add),
      ),
    );
  }
}

πŸ›  API #

useState<T>(T initialValue) #

Creates a ValueNotifier<T>.

final state = useState<String>('hello');

useStateBuilder<T>(ValueNotifier<T> value, Widget Function(T value) builder) #

A wrapper around ValueListenableBuilder to rebuild UI when state changes.

useStateBuilder(counter, (value) => Text('$value'));

πŸ€” Why use this? #

If you:

  • don’t want heavy frameworks
  • prefer simple and readable code
  • just need basic reactive state

πŸ‘‰ This is perfect for small to medium apps.


⚠️ Limitations #

  • Not suitable for very complex state logic
  • No dependency injection
  • No advanced features like scoped providers

πŸ“„ License #

MIT License


πŸ’‘ Contributing #

Feel free to open issues or submit pull requests!


0
likes
130
points
30
downloads

Documentation

API reference

Publisher

verified publishernimahedayati.ir

Weekly Downloads

A simple and lightweight state management library.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_simple_usestate