Intellij idea 运行dart项目时,dart:html不适用于独立vm
我用Git来拉一个项目 然后我启动IntelliJ,说:打开项目 项目本身看起来有4个模块,Lab1、Lab2、Solution2、Solution2 我打开整个项目。在Lab1中,我想运行以查看网页的外观,但当我说:Intellij idea 运行dart项目时,dart:html不适用于独立vm,intellij-idea,dart,Intellij Idea,Dart,我用Git来拉一个项目 然后我启动IntelliJ,说:打开项目 项目本身看起来有4个模块,Lab1、Lab2、Solution2、Solution2 我打开整个项目。在Lab1中,我想运行以查看网页的外观,但当我说:runmain.dart时,返回的错误是: C:\code\dart-sdk\bin\dart.exe --ignore-unrecognized-flags --checked --enable-vm-service:51293 --trace_service_pause_eve
runmain.dart
时,返回的错误是:
C:\code\dart-sdk\bin\dart.exe --ignore-unrecognized-flags --checked --enable-vm-service:51293 --trace_service_pause_events C:\code\workspace\tw_remoting_training\codelab_01\web\main.dart
Observatory listening on http://127.0.0.1:51293
The built-in library 'dart:html' is not available on the stand-alone VM.
'package:remoting_training/remoting_printer.dart': error: line 20 pos 1: library handler failed
import 'dart:html';
^
Process finished with exit code 254
不过我不知道这里发生了什么。作为第二个选项,我还将尝试右键单击index.html并单击:Open with>Dartium,但这将显示一个空白页面。它应该完成4个异步调用,将字符串打印到屏幕上
我有什么遗漏吗?它之所以没有运行是因为它是项目中的一个模块吗?如果您的Dart脚本导入
Dart:html
或导入Dart:html
的库,则只能从Dartium浏览器运行该脚本(通过向HTML添加脚本标记,指向该Dart脚本,或者在任何浏览器中通过pub build
或dart2js
运行该脚本),但不能从控制台运行该脚本
使用
dart:io
正好相反,它不能在浏览器中运行。那么,如何将一个flatter web项目编译为导入dart:html的apk?有什么解决方案吗?我还没有尝试flatter web,但我确信他们有办法在每个构建目标中包含不同的实现。我可以想象你需要为它构建一个插件但那只是一个猜测。