Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart/SQFlite Import Error

Tags:

flutter

dart

I am attempting to test out the SQFlite API by just creating a simple CLI. I can run the default sample app out of the same directory with both Android Studio and VS Code just fine and I can run other simple CLI programs just fine. Here is the contents of lib/cli.dart:

import 'package:sqflite/sqflite.dart';

void main() {
  print('SQFlite Test');    
}

When I run the code:

brianbuck$ dart --preview-dart-2 lib/cli.dart

I get the following error:

dart:ui: Error: Not found: dart:ui.

Here is the pub.spec file:

name: sqflite-test
description: SQFlite Test

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.0
  http: any
  sqflite: any

Is there a way to let the DartVM know that I have dart:ui installed?

like image 766
brian buck Avatar asked Oct 26 '25 09:10

brian buck


1 Answers

sqflite is for Flutter.

dart --preview-dart-2 lib/cli.dart is plain Dart entirely unrelated to Flutter.

If you have a dependency on dart:ui you can use dart ...., you have to use flutter run ...

Flutter has a customized SDK where dart:html and dart:mirrors are missing but has dart:ui missing in the Dart SDK.

like image 164
Günter Zöchbauer Avatar answered Oct 28 '25 21:10

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!