Skip to content
pubscout

provider_test

2.0.3, released 6 weeks ago by an unverified publisher

A testing library which makes it easy to test providers.

WASM-ready
$ flutter pub add provider_test
Source repository

What it does

Provides a testing utility function called testProvider that simplifies testing provider state changes over time. It handles checking expected states in order while an action is executed, and ensures no additional unexpected states are updated.

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

Use it when

  • You are using Provider for state management in your Flutter application
  • You want a structured and concise way to write unit tests for your providers

Skip it when

  • You are using state management solutions other than Provider, such as Bloc or Riverpod
  • You do not use unit tests in your project

Strengths

  • Simplifies testing provider state changes and notifications
  • Supports seed states, async operations via wait, and verification callbacks
  • Familiar API structure for developers coming from bloc_test

Weaknesses

  • Limited to the Provider state management library
  • Not documented for non-Flutter pure Dart packages

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
3

Add provider_test to dev_dependencies in pubspec.yaml.

testProvider(
  'CounterProvider updates state to [1] when increment() is called.',
  build: () => CounterProvider(),
  act: (provider) => provider.increment(),
  expect: {
    (provider) => provider.count: [1],
  },
);

Alternatives

Packages that do the same job and could replace provider_test.

Works with

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