Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter build_runner watch Not Working | The getter 'definingUnit' was called on null

After running flutter pub run build_runner watch --delete-conflicting-outputs

Build Runner Output

$ flutter pub run build_runner watch --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 402ms

[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 11.7s

[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 18ms

[INFO] Waiting for all file watchers to be ready...
[INFO] Waiting for all file watchers to be ready completed, took 87ms

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 968ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] 1.1s elapsed, 22/38 actions completed.
[INFO] 2.2s elapsed, 27/43 actions completed.
[INFO] 3.3s elapsed, 30/46 actions completed.
[INFO] 4.3s elapsed, 30/46 actions completed.
[INFO] 6.3s elapsed, 30/46 actions completed.
[INFO] 13.3s elapsed, 57/72 actions completed.
[INFO] 14.3s elapsed, 123/139 actions completed.
[INFO] 15.5s elapsed, 142/158 actions completed.
[INFO] 16.5s elapsed, 160/176 actions completed.
[INFO] 17.6s elapsed, 168/184 actions completed.
[INFO] 18.6s elapsed, 176/192 actions completed.
[INFO] 19.7s elapsed, 191/207 actions completed.
[SEVERE] auto_route_generator:autoRouteGenerator on lib/application/auth/auth_Bloc/auth_bloc.dart:

NoSuchMethodError: The getter 'definingUnit' was called on null.
Receiver: null
Tried calling: definingUnit
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      LinkedElementFactory.isLibraryUri (package:analyzer/src/summary2/linked_element_factory.dart:133:28)
#2      LibraryContext.isLibraryUri (package:analyzer/src/dart/analysis/library_context.dart:97:27)
#3      LibraryAnalyzer._isLibrarySource (package:analyzer/src/dart/analysis/library_analyzer.dart:522:25)
#4      LibraryAnalyzer._resolveDirectives (package:analyzer/src/dart/analysis/library_analyzer.dart:562:36)
#5      LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:136:5)
#6      LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:107:12)
#7      AnalysisDriver._computeAnalysisResult2.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1317:63)
#8      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
#9      AnalysisDriver._computeAnalysisResult2 (package:analyzer/src/dart/analysis/driver.dart:1294:20)
#10     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1247:14)
#11     _rootRun (dart:async/zone.dart:1190:13)
#12     _CustomZone.run (dart:async/zone.dart:1093:19)
#13     _runZoned (dart:async/zone.dart:1630:10)
#14     runZoned (dart:async/zone.dart:1550:10)
#15     NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
#16     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1246:40)
#17     AnalysisDriver._computeErrors (package:analyzer/src/dart/analysis/driver.dart:1372:41)
#18     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:979:20)
#19     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2013:24)
<asynchronous suspension>
#20     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:1936:5)
#21     analysisDriver (package:build_resolvers/src/analysis_driver.dart:62:13)
#22     AnalyzerResolvers._ensureInitialized.<anonymous closure> (package:build_resolvers/src/resolver.dart:306:26)
<asynchronous suspension>
#23     AnalyzerResolvers._ensureInitialized.<anonymous closure> (package:build_resolvers/src/resolver.dart)
#24     AnalyzerResolvers._ensureInitialized (package:build_resolvers/src/resolver.dart:309:6)
#25     AnalyzerResolvers.get (package:build_resolvers/src/resolver.dart:314:11)
#26     PerformanceTrackingResolvers.get.<anonymous closure> (package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart:19:58)
#27     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:302:15)
#28     PerformanceTrackingResolvers.get (package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart:19:16)
#29     BuildStepImpl.resolver (package:build/src/builder/build_step_impl.dart:74:54)
#30     _Builder.build (package:source_gen/src/builder.dart:72:32)
#31     runBuilder.buildForInput (package:build/src/generate/run_builder.dart:55:21)
#32     MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
#33     ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
#34     Future.wait (dart:async/future.dart:406:26)
#35     runBuilder.<anonymous closure> (package:build/src/generate/run_builder.dart:61:36)
#36     _rootRun (dart:async/zone.dart:1190:13)
#37     _CustomZone.run (dart:async/zone.dart:1093:19)
#38     _runZoned (dart:async/zone.dart:1630:10)
#39     runZonedGuarded (dart:async/zone.dart:1618:12)
#40     runZoned (dart:async/zone.dart:1547:12)
#41     scopeLogAsync (package:build/src/builder/logging.dart:26:3)
#42     runBuilder (package:build/src/generate/run_builder.dart:61:9)
#43     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:485:19)
#44     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:302:15)
#45     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:483:23)
<asynchronous suspension>
#46     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart)
#47     NoOpTimeTracker.track (package:timing/src/timing.dart:222:44)
#48     _SingleBuild._runForInput.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:440:22)
#49     Pool.withResource (package:pool/pool.dart:127:28)
<asynchronous suspension>
#50     _SingleBuild._runForInput (package:build_runner_core/src/generate/build_impl.dart:436:17)
#51     _SingleBuild._runBuilder.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:374:38)
#52     MappedIterator.moveNext (dart:_internal/iterable.dart:392:20)
#53     Future.wait (dart:async/future.dart:406:26)
#54     _SingleBuild._runBuilder (package:build_runner_core/src/generate/build_impl.dart:373:36)
#55     _SingleBuild._runPhases.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:319:20)
<asynchronous suspension>
#56     _SingleBuild._runPhases.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart)
#57     _NoOpBuildPerformanceTracker.trackBuildPhase (package:build_runner_core/src/generate/performance_tracker.dart:184:15)
#58     _SingleBuild._runPhases.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:315:47)
#59     NoOpTimeTracker.track (package:timing/src/timing.dart:222:44)
#60     _SingleBuild._runPhases (package:build_runner_core/src/generate/build_impl.dart:309:32)
#61     logTimedAsync (package:build_runner_core/src/logging/logging.dart:25:30)
#62     _SingleBuild._safeBuild.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:266:26)
#63     _rootRun (dart:async/zone.dart:1190:13)
#64     _CustomZone.run (dart:async/zone.dart:1093:19)
#65     _runZoned (dart:async/zone.dart:1630:10)
#66     runZonedGuarded (dart:async/zone.dart:1618:12)
#67     runZoned (dart:async/zone.dart:1547:12)
#68     _SingleBuild._safeBuild (package:build_runner_core/src/generate/build_impl.dart:261:5)
#69     _SingleBuild.run (package:build_runner_core/src/generate/build_impl.dart:208:24)
#70     BuildImpl.run (package:build_runner_core/src/generate/build_impl.dart:94:56)
#71     WatchImpl._run.<anonymous closure> (package:build_runner/src/generate/watch_impl.dart:337:14)
<asynchronous suspension>
#72     WatchImpl._run.<anonymous closure> (package:build_runner/src/generate/watch_impl.dart)
#73     WatchImpl._run (package:build_runner/src/generate/watch_impl.dart:355:6)
#74     new WatchImpl (package:build_runner/src/generate/watch_impl.dart:196:20)
#75     _runWatch (package:build_runner/src/generate/watch_impl.dart:127:5)
#76     watch (package:build_runner/src/generate/watch_impl.dart:85:15)
#77     _rootRunUnary (dart:async/zone.dart:1198:47)
#78     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#79     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#80     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#81     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#82     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#83     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#84     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#85     BuildOptions.create (package:build_runner_core/src/generate/options.dart)
#86     _rootRunUnary (dart:async/zone.dart:1198:47)
#87     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#88     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#89     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#90     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#91     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#92     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#93     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#94     TargetGraph.forPackageGraph (package:build_runner_core/src/package_graph/target_graph.dart)
#95     _rootRunUnary (dart:async/zone.dart:1198:47)
#96     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#97     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#98     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#99     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#100    Future._completeWithValue (dart:async/future_impl.dart:529:5)
#101    _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#102    _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#103    _packageBuildConfig (package:build_runner_core/src/package_graph/target_graph.dart)
#104    _rootRunUnary (dart:async/zone.dart:1198:47)
#105    _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#106    _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#107    Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#108    Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#109    Future._completeWithValue (dart:async/future_impl.dart:529:5)
#110    _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#111    _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#112    BuildConfig.fromBuildConfigDir (package:build_config/src/build_config.dart)
#113    _rootRunUnary (dart:async/zone.dart:1198:47)
#114    _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#115    _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#116    Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#117    Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#118    Future._completeWithValue (dart:async/future_impl.dart:529:5)
#119    Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#120    _rootRun (dart:async/zone.dart:1190:13)
#121    _CustomZone.run (dart:async/zone.dart:1093:19)
#122    _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
#123    _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#124    _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#125    _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#126    _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

[INFO] 21.0s elapsed, 196/212 actions completed.
[INFO] 22.1s elapsed, 196/212 actions completed.
[INFO] 23.2s elapsed, 196/212 actions completed.
[INFO] 24.2s elapsed, 196/212 actions completed.
[INFO] 25.3s elapsed, 196/212 actions completed.
[INFO] 26.4s elapsed, 196/212 actions completed.
[INFO] 27.5s elapsed, 196/212 actions completed.
[INFO] 28.6s elapsed, 196/212 actions completed.
[INFO] 29.6s elapsed, 196/212 actions completed.
[INFO] 30.7s elapsed, 196/212 actions completed.
[INFO] 31.8s elapsed, 196/212 actions completed.
[INFO] 32.8s elapsed, 196/212 actions completed.
[INFO] 33.9s elapsed, 196/212 actions completed.
[INFO] 35.0s elapsed, 196/212 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/product_list/widget/product_list_body_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/addToCart_Icon_Button.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/quantity_changer.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/sidenav/store_sidenav_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/favourite/store_favourite_page.dart
  .. and 11 more

[INFO] 36.1s elapsed, 196/212 actions completed.
[INFO] 37.2s elapsed, 196/212 actions completed.
[INFO] 38.3s elapsed, 196/212 actions completed.
[INFO] 39.3s elapsed, 196/212 actions completed.
[INFO] 40.4s elapsed, 196/212 actions completed.
[INFO] 41.5s elapsed, 196/212 actions completed.
[INFO] 42.6s elapsed, 196/212 actions completed.
[INFO] 43.6s elapsed, 196/212 actions completed.
[INFO] 44.7s elapsed, 196/212 actions completed.
[INFO] 45.8s elapsed, 196/212 actions completed.
[INFO] 46.9s elapsed, 196/212 actions completed.
[INFO] 47.9s elapsed, 196/212 actions completed.
[INFO] 48.9s elapsed, 196/212 actions completed.
[INFO] 50.0s elapsed, 196/212 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/product_list/widget/product_list_body_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/addToCart_Icon_Button.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/quantity_changer.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/sidenav/store_sidenav_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/favourite/store_favourite_page.dart
  .. and 11 more

[INFO] 51.2s elapsed, 196/212 actions completed.
[INFO] 52.3s elapsed, 196/212 actions completed.
[INFO] 53.4s elapsed, 196/212 actions completed.
[INFO] 54.4s elapsed, 196/212 actions completed.
[INFO] 55.5s elapsed, 196/212 actions completed.
[INFO] 56.6s elapsed, 196/212 actions completed.
[INFO] 57.6s elapsed, 196/212 actions completed.
[INFO] 58.6s elapsed, 196/212 actions completed.
[INFO] 59.7s elapsed, 196/212 actions completed.
[INFO] 1m 0s elapsed, 196/212 actions completed.
[INFO] 1m 1s elapsed, 196/212 actions completed.
[INFO] 1m 2s elapsed, 196/212 actions completed.
[INFO] 1m 4s elapsed, 196/212 actions completed.
[INFO] 1m 5s elapsed, 196/212 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/product_list/widget/product_list_body_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/addToCart_Icon_Button.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/quantity_changer.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/sidenav/store_sidenav_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/favourite/store_favourite_page.dart
  .. and 11 more

[INFO] 1m 6s elapsed, 196/212 actions completed.
[INFO] 1m 7s elapsed, 196/212 actions completed.
[INFO] 1m 8s elapsed, 196/212 actions completed.
[INFO] 1m 9s elapsed, 196/212 actions completed.
[INFO] 1m 10s elapsed, 196/212 actions completed.
[INFO] 1m 11s elapsed, 196/212 actions completed.
[INFO] 1m 12s elapsed, 196/212 actions completed.
[INFO] 1m 13s elapsed, 196/212 actions completed.
[INFO] 1m 14s elapsed, 196/212 actions completed.
[INFO] 1m 15s elapsed, 196/212 actions completed.
[INFO] 1m 17s elapsed, 196/212 actions completed.
[INFO] 1m 18s elapsed, 196/212 actions completed.
[INFO] 1m 19s elapsed, 196/212 actions completed.
[INFO] 1m 20s elapsed, 196/212 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/product_list/widget/product_list_body_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/addToCart_Icon_Button.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/quantityChanger/quantity_changer.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/core/sidenav/store_sidenav_widget.dart
  - auto_route_generator:autoRouteGenerator on lib/presentation/pages/store/favourite/store_favourite_page.dart
  .. and 11 more

[INFO] 1m 21s elapsed, 196/212 actions completed.
[INFO] 1m 22s elapsed, 196/212 actions completed.
[INFO] 1m 23s elapsed, 196/212 actions completed.
[INFO] 1m 24s elapsed, 196/212 actions completed.
[INFO] 1m 25s elapsed, 196/212 actions completed.
[INFO] 1m 26s elapsed, 196/212 actions completed.
Terminate batch job (Y/N)? y

My pubspec.yaml

    name: Test Flutter 
    description: A new Flutter project.
    
    publish_to: "none"
    
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.9.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      analyzer: ^0.40.6
      auto_route: ^0.6.9
      badges: ^1.1.4
      cached_network_image: ^2.3.3
      cloud_firestore: ^0.14.2
      cloud_functions: ^0.6.0+1
      cupertino_icons: ^1.0.0
      curved_navigation_bar: ^0.3.4
      dartz: ^0.9.2
      firebase_auth: ^0.18.2
      firebase_cloud_messaging: ^4.0.4+1
      firebase_core: ^0.5.1
      flushbar: ^1.10.4
      flutter_bloc: ^6.0.6
      flutter_hooks: ^0.14.1
      freezed_annotation: ^0.12.0
      get_it: ^5.0.1
      google_sign_in: ^4.5.5
      injectable: ^1.0.5
      json_annotation: ^3.1.0
      kt_dart: ^0.8.0
      razorpay_flutter: ^1.2.2
      rxdart: ^0.24.1
      uuid: ^2.2.2
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
      auto_route_generator: ^0.6.9
      build_runner: ^1.10.4
      flutter_launcher_icons: ^0.8.1
      freezed: ^0.12.2
      injectable_generator: ^1.0.6
      json_serializable: ^3.5.0
      lint: ^1.3.0
    
    flutter_icons:
      android: "launcher_icon"
      ios: true
      image_path: "assets/images/sblogo.png"
    
    flutter:
      uses-material-design: true
    
      assets:
        - assets/images/checked.png
        - assets/images/cancel.png
        - assets/images/sblogo.png
        - assets/images/brand.png

Flutter Doctor output:


    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.19041.572], locale en-IN)
    
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [√] Android Studio (version 4.0)
    [√] VS Code (version 1.50.1)
    [!] Connected device
        ! No devices available
    
    ! Doctor found issues in 1 category.

I am stuck on this for the last 2 days. Please Help. Thank you.

like image 873
Alex Bryson Avatar asked Nov 03 '20 07:11

Alex Bryson


2 Answers

To me, arpit solution worked: "Downgrading build_runner to 1.10.2".

(Added on 27 November 2020):

In other cases, the problem may arise if there is some import with "//" in it, eg.:

`import 'package:path//name.dart'.

Here is a regular expression to find the "import" that have "//" in the same line:

(import).*?(//).*?

This solution is taken from https://github.com/google/json_serializable.dart/issues/738, see dotdotcommadot answer.

like image 154
Fabio Pagano Avatar answered Nov 19 '22 04:11

Fabio Pagano


I was having this same issue earlier today. For me what worked was delete all tests files and making the build_runner downgrade to 1.10.2. I know this is not the best solution but it is a workaround for a while.

like image 1
Nunoobjr Avatar answered Nov 19 '22 05:11

Nunoobjr