I had been practicing riverpod in flutter with riverpod_generator and everything was working fine.
The command dart run build_runner watch -d
was also running perfectly and generating .g.dart
files when suddenly something went wrong and I was being shown this error when running build runner:
user@name MINGW64 /a/flutter_code/aa
$ dart run build_runner build -v
[INFO] Entrypoint:Generating build script...
[INFO] Entrypoint:Generating build script completed, took 663ms
[INFO] Bootstrap:Precompiling build script......
[WARNING] Bootstrap:
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/functional_provider.dart:38:33: Error: The getter
'createdType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
final returnType = provider.createdType;
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/functional_provider.dart:61:48: Error: The getter
'valueType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
final $providerName = $providerType<${provider.valueType}>.internal(
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/functional_provider.dart:69:50: Error: The getter
'valueType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
typedef $refName = ${providerType}Ref<${provider.valueType}>;
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/class_based_provider.dart:101:33: Error: The getter 'createdType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
final returnType = provider.createdType;
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/class_based_provider.dart:115:66: Error: The getter 'valueType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
final $providerName = $providerType<${provider.name}, ${provider.valueType}>.internal(
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/class_based_provider.dart:123:61: Error: The getter 'valueType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
typedef $notifierTypedefName = $notifierBaseType<${provider.valueType}>;
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:55:32: Error: The getter 'createdType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
var createdType = provider.createdType.toString();
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:57:33: Error: The getter 'createdType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
final returnType = provider.createdType;
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:65:44: Error: The getter 'valueType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
createdType = 'FutureOr<${provider.valueType}>';
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:90:38: Error: The getter 'valueType' isn't defined for the class 'FunctionalProviderDeclaration'.
- 'FunctionalProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
providerGenerics: '<${provider.valueType}>',
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:134:33: Error: The getter 'createdType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
final returnType = provider.createdType;
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:167:56: Error: The getter 'valueType'
isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
providerGenerics: '<${provider.name}, ${provider.valueType}>',
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:172:74: Error: The getter 'valueType'
isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
abstract class $notifierTypedefName extends $notifierBaseType<${provider.valueType}> {
^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:175:14: Error: The getter 'createdType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
${provider.createdType} build($parameterDefinition);
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:180:14: Error: The getter 'createdType' isn't defined for the class 'ClassBasedProviderDeclaration'.
- 'ClassBasedProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'createdType'.
${provider.createdType} runNotifierBuild(
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:248:45: Error: The getter 'exposedType' isn't defined for the class 'GeneratorProviderDeclaration'.
- 'GeneratorProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'exposedType'.
class $familyName extends Family<${provider.exposedType}> {
^^^^^^^^^^^
/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_generator-2.3.4/lib/src/templates/family.dart:332:43: Error: The getter 'valueType'
isn't defined for the class 'GeneratorProviderDeclaration'.
- 'GeneratorProviderDeclaration' is from 'package:riverpod_analyzer_utils/src/riverpod_ast.dart' ('/C:/Users/user@name/AppData/Local/Pub/Cache/hosted/pub.dev/riverpod_analyzer_utils-0.4.1/lib/src/riverpod_ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'valueType'.
mixin $refNameImpl on $refType<${provider.valueType}> {
^^^^^^^^^
[INFO] Bootstrap:Precompiling build script... completed, took 1.9s
[SEVERE] Bootstrap:
Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
pubspec.yaml:
name: aa
description: A new Flutter project.
publish_to: "none"
version: 0.1.0
environment:
sdk: ">=3.1.4 <4.0.0"
dependencies:
flutter:
sdk: flutter
flutter_riverpod: ^2.4.4
riverpod_annotation: ^2.2.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
riverpod_generator: ^2.3.4
build_runner: ^2.4.6
custom_lint: ^0.5.4
riverpod_lint: ^2.0.2
flutter:
uses-material-design: true
What I have already tried:
flutter clean
-> flutter pub cache clean
-> dart run build_runner build clean
flutter pub upgrade --major-versions
It's been two days since I am stuck at this point and finding no solutions. Asking it here is last option for me. Kindly ask for any more info if needed and provide me the solution to start practicing again.
It seems like the latest versions of riverpod isn't working. This issue gives more context: https://github.com/rrousselGit/riverpod/issues/2943
EDIT: A workaround that worked for me was to use riverpod_generator 3.0.0-dev.3. See this comment: https://github.com/rrousselGit/riverpod/issues/3005#issuecomment-1766892690
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With