错误状态:意外诊断:在 flutter 升级到 1.20.1 之后

Bad state: Unexpected diagnostics: after flutter upgrade to 1.20.1

有什么问题?

xxx@xxx-Inspiron-14-3467:~/xxx$ flutter pub run build_runner build[INFO] Generating build script...
[INFO] Generating build script completed, took 406ms

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

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

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

[INFO] Running build...
[INFO] Generating SDK summary...
[SEVERE] chopper_generator:chopper_generator on test/widget_test.dart:

Bad state: Unexpected diagnostics:
/home/xxx/Desktop/flutter_linux_1.20.1-stable/flutter/bin/cache/dart-sdk/lib/core/uri.dart:3259:39 - Expected an identifier.
[SEVERE] chopper_generator:chopper_generator on test/widget_test.dart:

Bad state: Unexpected diagnostics:
/home/xxx/Desktop/flutter_linux_1.20.1-stable/flutter/bin/cache/dart-sdk/lib/core/uri.dart:3259:39 - Expected an identifier.
[INFO] 1.6s elapsed, 1/17 actions completed.
[INFO] 2.7s elapsed, 1/17 actions completed.
[INFO] 3.8s elapsed, 1/17 actions completed.
[INFO] 4.9s elapsed, 1/17 actions completed.
[INFO] 6.0s elapsed, 1/17 actions completed.
[INFO] 7.1s elapsed, 1/17 actions completed.
[INFO] 8.2s elapsed, 1/17 actions completed.
[INFO] 9.3s elapsed, 1/17 actions completed.
[INFO] 10.4s elapsed, 1/17 actions completed.
[INFO] 11.5s elapsed, 1/17 actions completed.
[INFO] 12.6s elapsed, 1/17 actions completed.
[INFO] 13.7s elapsed, 1/17 actions completed.
[INFO] 14.8s elapsed, 1/17 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - chopper_generator:chopper_generator on lib/repository/model/radio_model.dart
  - chopper_generator:chopper_generator on lib/repository/model/xxx.dart
  - chopper_generator:chopper_generator on lib/repository/model/time.dart
  - chopper_generator:chopper_generator on lib/repository/model/assign_to.dart
  - chopper_generator:chopper_generator on lib/repository/model/defect_cases_count.dart
  .. and 11 more

花了3个多小时,终于解决了。

已经升级到flutter 1.20.1以上版本的朋友,一定要在pubspec.yaml里加上这行。

dependency_overrides:
  analyzer: '0.39.14'

我遇到了同样的问题:

请在您的 pubspec 文件中试试这个

dependency_overrides:
  analyzer: '0.39.17'    
  build_resolvers: '1.3.10'

试一试:

1- flutter clean

2- 继续开发频道:flutter channel dev

3-升级:flutter upgrade --force

4- flutter pub get

5- 尝试构建

6- 回到稳定频道或主频道:flutter channel stable (flutter channel master)

7- 升级:flutter upgrade --force

我遇到了同样的问题,如果接受的答案没有解决您的问题,您可以尝试 this issue:

中描述的过程
  • flutter clean
  • flutter pub get
  • flutter packages upgrade