Problem with using annotation @riverpod in working with Riverpod

93 Views Asked by At

Im following offical documentation and while trying to use @riverpod annotation in my code im getting error: "Undefined class 'HelloWorldRef' "

I tried to create provider like in documentation:

@riverpod
String helloWorld(HelloWorldRef ref) {
  return 'Hello world';
}
1

There are 1 best solutions below

0
On BEST ANSWER

You have first to ensure that you have all packages installed in your project.

flutter pub add flutter_riverpod
flutter pub add riverpod_annotation
flutter pub add dev:riverpod_generator
flutter pub add dev:build_runner
flutter pub add dev:custom_lint
flutter pub add dev:riverpod_lint

now you can run the code-generator with flutter pub run build_runner watch