question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Not found: 'dart:ui' when trying to run a Flutter project

See original GitHub issue

Trying to run a Flutter project in VS Code yields many errors like this: Error: Not found: 'dart:ui'.

From looking at other issues (#2038, #1827) I understand that this is caused by trying to run a Dart project rather than a Flutter project. Well, I believe this is not the case in my project since the status bar does show Flutter and its version, in addition to selection of an emulator. The doctor also reports no issues whatsoever.

To Reproduce

I cannot share my code with the community (closed source), but the project opens and runs fine in both Android Studio and IntelliJ IDEA. The top-level directory contains a pubspec.yaml with a line reading sdk: "flutter".

Expected behavior The project runs as a Flutter project.

Screenshots

Screenshot_2022-02-17_08-52-14

Screenshot_2022-02-17_08-53-30

Screenshot_2022-02-17_09-02-17

Versions (please complete the following information):

  • VS Code version: 1.64.2
  • Dart extension version: 3.34.0
  • Dart/Flutter SDK version: Flutter 2.11.0-0.0.pre.582 • channel master • Dart 2.17.0 (build 2.17.0-105.0.dev)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
DanTupcommented, Sep 17, 2022

@Chetan34123456 the two most common cases of this are:

  1. Project is not detected as a Flutter project. You can tell if this is the case because it was show a Dart SDK version (“Dart x.y.z”) in the status bar, or the words “Dart from Flutter”. If it shows “Flutter x.y.z” in the status bar, then this is not the problem. If this is the problem, it’s usually caused by not opening the Flutter projects folder correctly, or not having Flutter correctly referenced in the pubspec.yaml.
  2. Clicking the Run buttons contributed by the Code Runner extension. Code Runner does not understand Flutter projects and tries to run everything with Dart. If this is the problem you should just launch the app using F5 or the “other” run button, or the Run menu.

If it’s neither of these, please run the Dart: Capture Debugging Logs command from the command palette (F1), try to run the app (to generate the error), then click Cancel on the logging notification to stop logging and open the log file, then file a new issue with the log attached.

Note: The log will contain parts of your source, so best to repro in a clean project (created with the Flutter: New Project command).

1reaction
juank27commented, Aug 23, 2022

if you have the code runner extension installed, you may end up with that extension and not the flutter one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dart:ui:1: Error: Not found: dart:ui. flutter/dart: - Stack Overflow
When running the app, you will find 2 main.dart Choose the one with the flutter icon beside it enter image description here.
Read more >
How to solve Not found: 'dart:ui' error while running integration ...
select Edit Configurations · Press the + button and select Flutter test · Make sure the Test scope is All in file and...
Read more >
flutter/flutter - Gitter
I have problem with Firestore, whem I try to use document Id with ... flutter/packages/flutter/lib/src/material/app.dart:7:8: Error: Not found: 'dart:ui' ...
Read more >
App Testing - Android Studio - FlutterFlow Community
I've downloaded my app code and opened it in Android Studio but get errors when i attempt to run the app. Issues in;...
Read more >
Unable to run new flutter sample code in IntelliJ IDEA
I clicked on build and got an error message. I ran Flutter Doctor and confirmed that i got no errors. The built-in library...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found