How to solve Not found: 'dart:ui' error while running integration tests on Flutter


I have an app, it is very simple and have just one widget. It is working fine, however when I run integration test by calling:

$ flutter drive --target=test_driver/app.dart 

I get the following error:

 file:///Users/myuser/flutter/packages/flutter_test/lib/src/accessibility.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
file:///Users/myuser/flutter/packages/flutter_test/lib/src/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:9:8: Error: Not found: 'dart:ui'
import 'dart:ui';
file:///Users/myuser/flutter/packages/flutter_test/lib/src/test_pointer.dart:12:1: Error: Not found: 'dart:ui'
export 'dart:ui' show Offset;
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show window;
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/box.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show lerpDouble;
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/editable.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show TextBox;
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/error.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle;
Stopping application instance.
Driver tests failed: 254

Note that when I run the app from Android Studio, it runs successfully. But when I run from terminal using the command quoted above, the app shows a white screen and it doesn’t move from there until I get the error on my terminal.

Assuming it’s a path issue, like test_driver not finding flutter packages like dart:ui, how can I make sure test_driver knows where dart:ui is ?


I was getting these erros because I was trying to import a widget on a test_driver file. I also got the same error if I try to use find.byWidget.

I was trying to import a widget or use find.byWidget because I wanted to check the existence of a widget on a screen.

These erros are pretty much similar to

The built-in library ‘dart:ui’ is not available on the stand-alone VM.

Then, in order to check the existence of a widget on screen in a test_driver file, I had to use find.byKeyValue. For example, given the following dummy widget, defined in a file within my app:

class MyDummyWidget extends StatelessWidget {

  MyDummyWidget(): super(key: new Key('MyDummyWidget'));

  Widget build(BuildContext context) {
    return Center();

To check if it is being displayed on screen, I define the following test within the test_driver:

void main() {
  group('My tests', () {
    FlutterDriver driver;
    SerializableFinder myDummyWidget = find.byValueKey('MyDummyWidget');

    setUpAll(() async {
      driver = await FlutterDriver.connect();

    tearDownAll(() async {
      if (driver != null) {

    test('check if MyDummyWidget is being displayed', () async {
      await driver.waitFor(myDummyWidget);

Where the key definition is the required one in the first file, and then, the find.byValueKey and await driver ones are the essentials in the test file.

Answered By – RobertoAllende

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.