mirror of
https://github.com/rrousselGit/riverpod.git
synced 2025-08-26 20:20:18 +08:00
23 lines
636 B
Dart
23 lines
636 B
Dart
import 'package:riverpod/riverpod.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
/// A testing utility which creates a [ProviderContainer] and automatically
|
|
/// disposes it at the end of the test.
|
|
ProviderContainer createContainer({
|
|
ProviderContainer? parent,
|
|
List<Override> overrides = const [],
|
|
List<ProviderObserver>? observers,
|
|
}) {
|
|
// Create a ProviderContainer, and optionally allow specifying parameters.
|
|
final container = ProviderContainer(
|
|
parent: parent,
|
|
overrides: overrides,
|
|
observers: observers,
|
|
);
|
|
|
|
// When the test ends, dispose the container.
|
|
addTearDown(container.dispose);
|
|
|
|
return container;
|
|
}
|