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

6k Views Asked by At

I'm trying to run the build_runner build command:

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

But I'm getting the following error:

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

UPDATE 2020-07-25:

I already tried to run flutter clean, flutter pub get and change my pubspec.yaml in different ways and with different combinations of different dependency versions, but the problem keeps happening.

I even found an issue that presents a very similar problem, but in the context of testing, which is not my case.

To make it easier to identify the problem, I am posting my 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/
1

There are 1 best solutions below

0
On BEST ANSWER

I had the same problem, and found that I had by accident imported a flutter package in my Generator file. Removing the useless import fixed the issue.