Search packages, repositories and app categories

Package detailsv0.10.0

flutter_state_management

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
296
Likes
4
Pub points
160

Install package

flutter pub add flutter_state_management

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight package that simplifies state management in Flutter by providing helper classes for working with ChangeNotifier. It reduces boilerplate code and enhances developer productivity when managing app state. Designed to integrate seamlessly with Flutter's reactive framework, it supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. The package is ideal for developers seeking a minimal, clean approach to state handling without the complexity of larger state management solutions.

Use cases

  • Simple state updates in small apps
  • Reducing boilerplate in ChangeNotifier implementations
  • Streamlining state logic in forms and UI components
  • Managing shared data across multiple widgets
  • Lightweight alternative to BLoC or Provider

Key features

  • Helper classes for ChangeNotifier
  • Minimal setup and integration
  • Cross-platform support
  • Clean and readable code structure
  • Built-in utilities for common state patterns

Suitable for

  • Beginner Flutter developers
  • Small to medium-sized projects
  • Apps needing basic state management
  • Developers preferring simplicity over complexity
  • Teams wanting fast prototyping

Considerations

  • Not suitable for complex state flows
  • Limited compared to full-featured state management libraries
  • May require additional tooling for large-scale apps
  • Best used with other state management approaches when scaling
  • Does not include built-in persistence or async handling

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Flutter State Management

Just a couple of utility classes to make it easier to use Flutter framework's built-in ChangeNotifier and Listenable for state management.

Features

  • No learning curve if you already know Flutter
  • Simple package based on ChangeNotifier (No bloatware)

Usage

Create your model class

class Counter extends StateNotifier<int, String> {
  Counter() : super(const Active(data: 0));

  void increment() async {
    setWaiting();

    await Future.delayed(const Duration(seconds: 2));

    if (data > 20) {
     setFailed('greater than 20');
    } else {
      setActive(data + 1);
    }
  }
}

Or if you want the state to persist across restarts

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

  void increment() async {
    setWaiting();

    await Future.delayed(const Duration(seconds: 2));

    if (data > 20) {
      setFailed('greater than 20');
    } else {
      setActive(data + 1);
    }
  }
}

Handle State Changes in UI

To only rebuild specific parts:
  1. Use ValueListenableBuilder from the Flutter framework:
final counter = Counter();

ValueListenableBuilder(
  valueListenable: counter,
  child: Text()
  builder: (context, state, child) => // return updated UI here (can also use counter.builderArg here)
  child: const Text('Hello'),
  ),
);

You can also use builderArg helper:

builder: counter.builderArg(
  onActive: ,
  onWaiting: ,
  onNone: ,
  onFailure: ,
),
  1. Or use StateNotifierBuilder that comes with this package and is more user friendly:
final counter = Counter();

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


\

To rebuild whole widget

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

class CounterText extends RStatelessWidget {
  @override
  Widget build(BuildContext context) {
    counter.watch(context); // call watch inside the build method (do not use any if) 
    return Text(data.toString());
  }
}

Categories

Source repository

Projects using this package

No data available yet.