Conceptos clave

The package intentionally narrows features a keep behavior explicit: provider identity by args, scoped injection, y predictable disposal semantics.

What Changes de Riverpod

Instead de generated family classes y implicit notifier channels, miniriverpod prefers subclass + args + explicit invoke.

Provider identity

runtimeType + args hash

family alternative

Subclass Provider / AsyncProvider y pass super.args((...))

DI fallback

Scope<T>.required + overrideWithValue

Why this matters

You can reason about equality y overrides de plain Dart constructors, which keeps debugging y tests straightforward.

Provider Identity con args

args defines the provider key, so equal args means the same cache entry inside a ProviderContainer.

Identity rule

ProviderKey = runtimeType + hash(args)

Practical consequences

- No dedicated family type is required.
- Per-argument override is done by creating provider instances.
- Keep args stable and immutable for predictable caching.

ejemplo: family-like provider + Scope fallback

Use a constructor argument as identity y inject a fallback instance through Scope.

product_provider.dart
class ProductProvider extends AsyncProvider<List<Product>> {
  ProductProvider({this.search = ''}) : super.args((search,));
  final String search;

  static final fallback = Scope<ProductProvider>.required('product.fallback');

  @override
  FutureOr<List<Product>> build(ref) async {
    final api = ref.watch(productsApiProvider);
    return api.search(q: search);
  }
}

// Inject
ProviderScope(
  overrides: [
    ProductProvider.fallback.overrideWithValue(ProductProvider(search: 'jeans')),
  ],
  child: const App(),
);
Scope keeps dependency wiring explicit y test-friendly.
overrideWithValue works per provider instance, including args-based instances.
autoDispose behavior is unchanged by using subclass + args.

Siguientes pasos

providers & Reads

See concrete patterns para watch/read/listen y AsyncProvider.future.

Open providers

Mutations

Implement state updates con mutation tokens, mutate, y ref.invoke.

Open mutaciones