Dart-code: Dart UI error

Created on 2 Jul 2019  ·  4Comments  ·  Source: Dart-Code/Dart-Code

I pasted the demo code from google, it was ok. And several times later, the following appeared:
the code has nothing wrong. I put it in Android Studio and the right info appeared in the phone. I reinstalled vs code, started a new project. But the problem is still there. Anyone can help?

The following is the demo code from google flutter website:

 import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Welcome to Flutter',
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Welcome to Flutter'),
        ),
        body: new Center(
          child: new Text("what's wrong?"),
        ),
      ),
    );
  }
}

The following is the wrong info:

PS D:\app\flutter_app\aaa\sss> dart "d:\app\flutter_app\aaa\sss\lib\main.dart"
file:///d:/app/flutter_app/aaa/sss/lib/main.dart:1: Warning: Interpreting this as package URI, 'package:sss/main.dart'.
file:///C:/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:///C:/flutter/packages/flutter/lib/src/material/animated_icons.dart:10:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/app.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/app_bar_theme.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/arc.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/bottom_app_bar_theme.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/card_theme.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/chip_theme.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/colors.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show Color;
       ^
file:///C:/flutter/packages/flutter/lib/src/material/dialog_theme.dart:5:8: Error: Not found: 'dart:ui'import 'dart:ui' show lerpDouble;
is question

Most helpful comment

Errors loading dart:ui are usually caused by using a standard Dart SDK and not a Flutter SDK. Can you post your pubspec.yaml, and also how many levels deep the Flutter project is from the folder you opened in VS Code? (we only look a certain number of levels down the tree for Flutter projects).

All 4 comments

Errors loading dart:ui are usually caused by using a standard Dart SDK and not a Flutter SDK. Can you post your pubspec.yaml, and also how many levels deep the Flutter project is from the folder you opened in VS Code? (we only look a certain number of levels down the tree for Flutter projects).

Thank you Dan.
I am new to flutter,vscode. By your remind I realized that i used Dart SDK. Now the problem is solved!

Great, glad to hear!

Thank you Dan.
I am new to flutter,vscode. By your remind I realized that i used Dart SDK. Now the problem is solved!

can you show me the step?
Thanks in advance.

Was this page helpful?
0 / 5 - 0 ratings