如果出现以下错误,如何在 flutter 运行 中进行小部件测试?

How to make widget tests in flutter run if it gives the following error?

我的测试已经成功,但是当我将 Flutter 升级到新版本时,当我从命令行使用

运行 它时出现错误
flutter test test/widget_test.dart

错误是

00:05 +0 -1: loading /Users/lenz/plug_and_plink/test/widget_test.dart [E]                                                                                                                           
  Failed to load "/Users/lenz/project/test/widget_test.dart": type '(WidgetTester) => Future<Null>' is not a subtype of type '() => dynamic'
  package:flutter_test/src/test_compat.dart 171:29  test
  test/widget_test.dart 53:3                        main

00:05 +0 -1: Some tests failed. 

当我尝试 运行 来自 Android 工作室 UI 的测试时,它给出了另一个错误:

file:///Users/lenz/development/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;
       ^
file:///Users/lenz/development/flutter/packages/flutter/lib/src/material/animated_icons.dart:10:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///Users/lenz/development/flutter/packages/flutter/lib/src/material/app.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;

还有很多关于 'dart:ui' 的内容 怎样做才能让它再次发挥作用?

我通过删除 flutter 目录中的 /bin/cache/ 文件夹解决了这个问题。之后需要 运行

flutter precache

从命令行。似乎这些文件在 flutter 升级时没有更新