Files
riverpod/website/docs/essentials/testing/notifier_usage.dart
Remi Rousselet eb922a225e Change provider_name_strip_pattern to default wiht Notifier$ (#4237)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- Refactor
- Generated provider names were simplified: symbols now end with
"Provider" instead of "NotifierProvider". Update any app references and
samples.
- Documentation
- README and docs clarify the default strip pattern and examples now use
the new ...Provider names.
- Tests
  - Updated and added tests to assert the new default naming behavior.
- Chores
- Configuration parsing tightened to always supply default naming
values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-14 20:03:17 +02:00

29 lines
846 B
Dart

// ignore_for_file: unused_local_variable
import 'package:flutter_test/flutter_test.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'notifier_mock/codegen.dart';
/* SNIPPET START */
void main() {
test('Some description', () {
final container = ProviderContainer.test(
// {@template overrides}
// Override the provider to have it create our mock Notifier.
// {@endtemplate}
overrides: [myProvider.overrideWith(MyNotifierMock.new)],
);
// {@template readNotifier}
// Then obtain the mocked notifier through the container:
// {@endtemplate}
final notifier = container.read(myProvider.notifier);
// {@template interactNotifier}
// You can then interact with the notifier as you would with the real one:
// {@endtemplate}
notifier.state = 42;
});
}