Skip to content
pubscout

state_notifier_test

0.0.10, released 4 years ago by that-dev.me

A testing utility library for StateNotifier and Riverpod

WASM-ready
$ flutter pub add state_notifier_test
Source repository

What it does

Provides the stateNotifierTest function to easily test StateNotifier state emissions, actions, seeding, and verification, ported from bloc_test.

AI-written summary of version 0.0.10, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using state_notifier, riverpod, or flutter_riverpod in your project
  • You want a structured, readable syntax for testing state changes in StateNotifiers

Skip it when

  • You are not using StateNotifier or Riverpod for state management
  • You prefer standard Flutter test assertions without helper wrappers

Strengths

  • Clear, declarative syntax for testing emitted states
  • Supports seeding initial states, skipping emissions, and custom verifications

Weaknesses

  • Relies on a third-party port of bloc_test which may lag behind official bloc_test updates
  • Limited to StateNotifier architectures

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5

Add state_notifier_test to dev_dependencies in pubspec.yaml.

stateNotifierTest(
  'CounterNotifier emits [9,10] when seeded with 9',
  build: () => CounterNotifier(),
  seed: () => [9],
  actions: (stateNotifier) => stateNotifier.increment(),
  expect: () => [9,10],
);

Alternatives

Packages that do the same job and could replace state_notifier_test.

Works with

Packages commonly used together with state_notifier_test: ones it builds on, ones built on it, and its own family.