Error: Not found: 'dart:ui' on build_runner build

Error: Not found: 'dart:ui' on build_runner build

我正在尝试 运行 build_runner 构建命令:

$ flutter packages pub run build_runner build --delete-conflicting-outputs

但我收到以下错误:

C:\tools\flutter\bin\flutter.bat packages pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 703ms

[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 28.8s

[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] /C:/tools/flutter/packages/flutter/lib/src/material/animated_icons.dart:9:8: Error: Not found: 'dart:ui'import 'dart:ui' as ui show Paint, Path, Canvas;       ^/C:/tools/flutter/packages/flutter/lib/src/material/animated_icons.dart:10:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/app.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' as ui;       ^/C:/tools/flutter/packages/flutter/lib/src/material/app_bar_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/arc.dart:6:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/bottom_app_bar_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/bottom_sheet.dart:6:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/bottom_sheet_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/button_bar_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^/C:/tools/flutter/packages/flutter/lib/src/material/card_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;       ^
pub finished with exit code 78

Process finished with exit code 78

image of problem

2020 年 7 月 25 日更新:

我已经尝试 运行 flutter cleanflutter pub get 并以不同的方式和不同依赖版本的不同组合更改我的 pubspec.yaml,但问题一直在发生.

我什至发现了一个提出非常相似问题的问题,但在测试的上下文中,这不是我的情况。

为了更容易识别问题,我发布了我的 pubspec.yaml。

name: schema_widget
description: A Flutter package for dynamic widget creation.
version: 0.1.11
homepage: https://github.com/Legytma/schema_widget

environment:
  sdk: ">=2.1.0 <3.0.0"

legytma_schema:
  version: 1.1.2

dependencies:
  flutter:
    sdk: flutter
  logging: ^0.11.4
  get_it: ^4.0.4
  json_schema: ^2.2.1
  http: ^0.12.2
  google_maps_flutter: ^0.5.28+1
  flutter_spinkit: ^4.1.2+1
  build: ^1.3.0
  source_gen: ^0.9.6
  path_provider: ^1.6.11
  flutter_cache_manager: ^1.4.1
  rxdart:
  analyzer:
  glob:
  path:

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_driver:
    sdk: flutter
  effective_dart: ^1.2.4
  build_test: '>=1.0.0'
  build_runner: ^1.10.0
  dependency_validator: ^1.5.0

flutter:
  uses-material-design: true

  assets:
    - assets/
    - assets/LegytmaSchemas/schema/
    - assets/LegytmaSchemas/schema/widget/

我遇到了同样的问题,发现我不小心在我的Generator文件中导入了一个flutter包。删除无用的导入解决了这个问题。