Flutter build_runner 手表不工作 | getter 'definingUnit' 被调用为 null

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

在运行之后flutter pub run build_runner watch --delete-conflicting-outputs

构建运行器输出

$ 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

我的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 输出:


    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.

最近 2 天我一直卡在这个问题上。 请帮忙。 谢谢。

鉴于您的问题源于分析器并且您的构建正在等待 auto_route_generator 库,并且该库的版本比您使用的版本更新,因为它只有 change 有“将分析器版本限制为“>=0.40.0 <2.0.0” 我猜猜你应该更新它。

对我来说,arpit 解决方案有效:“将 build_runner 降级到 1.10.2”。

(2020 年 11 月 27 日添加):

在其他情况下,如果其中有一些带有“//”的导入,则可能会出现问题,例如:

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

这是一个正则表达式,用于查找同一行中包含“//”的“导入”:

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

此解决方案取自https://github.com/google/json_serializable.dart/issues/738,参见dotdotcommadot answer。

我今天早些时候遇到了同样的问题。对我来说,有效的方法是删除所有测试文件并使 build_runner 降级到 1.10.2。我知道这不是最好的解决方案,但它是暂时的解决方法。

在我的例子中,我有两个生成源代码的包:floor 持久性包(生成类似于 moorsqflite)和用于测试的 mockito .错误消息来自测试,例如:

[SEVERE] floor_generator:floor_generator on test/pace_string_test.dart:

NoSuchMethodError: The getter 'definingUnit' was called on null.
Receiver: null
Tried calling: definingUnit
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
...

解决方案是替换我测试中的任何相关导入以打包 URI 导入 (as suggested by miDeb on Github)。所以我更换了

import '../lib/track_my_indoor_exercise/tcx/tcx_model.dart';

import 'package:track_my_indoor_exercise/tcx/tcx_model.dart';