【发布时间】:2019-06-13 07:07:04
【问题描述】:
我在导入intl 后尝试运行我的应用程序,但它不起作用。
在pubspec.yaml 文件中我有:
intl: ^0.15.8
经过一番研究,我以三种方式导入了包,以确保确定。但似乎只使用了第一个(intl.dart):
import "package:intl/intl.dart";
import "package:intl/intl_browser.dart"; //unused import
import "package:intl/intl_standalone.dart"; //unused import
我就是这样用的:
DateFormat("dd-MM-yyyy").format(_chosenDate)
flutter run 之后我的错误是:
Resolving dependencies... 2,3s
Compiler message:
file:///Users/mydomus/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.15.8/lib/intl_browser.dart:25:48: Error: Getter not found: 'window'.
Intl.systemLocale = Intl.canonicalizedLocale(window.navigator.language);
^^^^^^
file:///Users/mydomus/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.15.8/lib/intl_browser.dart:13:8: Error: Not found: 'dart:html'
import "dart:html";
^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
#1 asFileUri (package:vm/kernel_front_end.dart:589:37)
<asynchronous suspension>
#2 FrontendCompiler._outputDependenciesDelta (package:vm/frontend_server.dart:391:39)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:vm/frontend_server.dart:365:13)
<asynchronous suspension>
#4 _FlutterFrontendCompiler.compile (package:frontend_server/server.dart:31:22)
<asynchronous suspension>
#5 starter (package:frontend_server/server.dart:133:27)
<asynchronous suspension>
#6 main (file:///b/s/w/ir/k/src/flutter/frontend_server/bin/starter.dart:8:30)
<asynchronous suspension>
#7 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:298:32)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
Compiler failed on /Users/mydomus/Desktop/meriem/flutter/mydomus_edl/lib/main.dart
我做错了吗?还是我应该报告的包裹问题?
【问题讨论】:
-
它是否在新的 Flutter 项目中运行?也许检查
flutter doctor -v是否有错误 -
我相信以下未使用的导入是原因,而不是 dateformat 之一。
import "package:intl/intl_browser.dart"; //unused import尝试删除此