Evandro Junior
Evandro Junior

Reputation: 558

dart run build_runner crashing with custom_lint warnings

I'm struggling to understand why build_runner is crashing.

[WARNING] ../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:816:30: Error: Type 'NullAwareElement' not found.
  void visitNullAwareElement(NullAwareElement node) {
                             ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:2156:28: Error: Type 'NullAwareElement' not found.
  final List<_Subscription<NullAwareElement>> _forNullAwareElement = [];
                           ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:2158:33: Error: Type 'NullAwareElement' not found.
      String key, void Function(NullAwareElement node) listener) {
                                ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:3359:42: Error: Type 'NullAwareElement' not found.
  void addNullAwareElement(void Function(NullAwareElement node) listener) {
                                         ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:816:30: Error: 'NullAwareElement' isn't a type.
  void visitNullAwareElement(NullAwareElement node) {
                             ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:818:11: Error: Superclass has no method named 'visitNullAwareElement'.
    super.visitNullAwareElement(node);
          ^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:2156:28: Error: 'NullAwareElement' isn't a type.
  final List<_Subscription<NullAwareElement>> _forNullAwareElement = [];
                           ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:2158:33: Error: 'NullAwareElement' isn't a type.
      String key, void Function(NullAwareElement node) listener) {
                                ^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/custom_lint_visitor-1.0.0+6.11.0/lib/src/node_lint_visitor.g.dart:3359:42: Error: 'NullAwareElement' isn't a type.
  void addNullAwareElement(void Function(NullAwareElement node) listener) {
                                         ^^^^^^^^^^^^^^^^
[INFO] Precompiling build script... completed, took 510ms
[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.

I already tried flutter pub cache repair, flutter pub cache clean, and flutter clean. I even changed package versions for older ones. The current example was done with the following package versions:

  build_runner: ^2.4.13
  isar_generator: *isar_version
  riverpod_generator: ^2.6.2
  custom_lint: ^0.7.0
  riverpod_lint: ^2.6.2

My flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on macOS 15.1 24B83 darwin-arm64, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.95.2)
[✓] Connected device (4 available)
[✓] Network resources

Upvotes: 2

Views: 204

Answers (1)

ivan-capk-me
ivan-capk-me

Reputation: 311

For me, the workaround was to downgrade the riverpod versions slightly. It's certainly not the right solution, but it may be useful until we find the right solution.

dev_dependencies:
  build_runner: 2.4.13
  riverpod_generator: 2.4.3
  custom_lint: 0.6.7
  riverpod_lint: 2.3.14

dependency_overrides:
  analyzer: 6.7.0

Upvotes: 0

Related Questions