| name | riverpod-provider-generator |
| description | Scaffolds a new Riverpod `@riverpod` class and (if needed) a corresponding Freezed state class, then triggers the build runner. |
Instructions
When the user asks to create a "Riverpod provider", "Notifier", or "State manager" using the code generation syntax (@riverpod):
- Ask for the name of the feature or provider.
- Create the Dart file with the necessary imports and boilerplate.
- Automatically include the
part directive for .g.dart (and .freezed.dart if they asked for a complex state).
Example Template:
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'my_feature_provider.g.dart';
@riverpod
class MyFeature extends _$MyFeature {
@override
int build() {
return 0; // Initial state
}
// Add methods to mutate state here
}
- Immediately after creating the file, open a terminal and execute the build runner to generate the part files (you can reference the
build-runner skill):
dart run build_runner build -d
- Confirm the generated provider is ready for use.