statescope 1.0.2 copy "statescope: ^1.0.2" to clipboard
statescope: ^1.0.2 copied to clipboard

Simple & performant state management using [InheritedNotifier].

pub package

StateScope #

A fork of Simple State Management

A state management solution that is light weight, easy to use, and performant. Uses Flutter's InheritedNotifier.

Features #

  • Ridiculously easy to use.
  • Light weight & performant.
  • Lazily load data.

Usage #

Store state in a class that extends ChangeNotifier, then create with StateScope.

StateScope(
    create: () => AppState(),
    child: ...
);

Data is lazily-loaded by default. To disable and load immediately when StateScope is built, set lazy to false.

StateScope(
    create: () => AppState(),
    lazy: false,
    child: ...
);

Access state via BuildContext wherever needed.

// DO rebuild widget when state changes.
context.watch<AppState>();

// DO NOT rebuild widget when state changes.
context.read<AppState>();

Pass data that has already been instantiated between BuildContexts by using StateScope.value.

final appState = context.read<AppState>();
Navigator.of(context).push(
    MaterialPageRoute(builder: (context) {
        return StateScope.value(
            value: appState,
            child: ...,
        );
    }),
);
2
likes
0
points
3
downloads

Publisher

verified publisheroykot.tokyo

Weekly Downloads

Simple & performant state management using [InheritedNotifier].

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on statescope