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

A collection of helper classes to make the use of ChangeNotifier easier for state management

Flutter State Management #

This is not a new state management solution. It is just a couple of utility classes to make it easier to use the Flutter framework's built-in ChangeNotifier and Listenable.

Features #

  • No learning curve if you already know Flutter
  • Simple package base on built-in ChangeNotifier (No bloatware)

Usage #

Create your model class

class Counter extends PersistedStateNotifier<int> {
  Counter() : super(IsarKeyValue(), startState: 0);

  void increment() => persistedState = Loaded(data: data + 1);
}



Use builder to handle state changes in the UI


counter.builder(
  onLoaded: (context, data) => Text(data.toString()),
),

Or convert your existing StatelessWidget to RStatelessWidget, and StatefulWidget to RStatefulWidget and just watch the model inside the build method

class CounterText extends RStatelessWidget {
  @override
  Widget build(BuildContext context) {
    counter.watch(context); // watch must be called inside the build method
    return Text(data.toString());
  }
}
3
likes
0
pub points
70%
popularity

Publisher

verified publishermuha.dev

A collection of helper classes to make the use of ChangeNotifier easier for state management

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, isar_key_value

More

Packages that depend on flutter_state_management