简体   繁体   English

内置库'dart:io'在Dartium上不可用

[英]The built-in library 'dart:io' is not available on Dartium

I don't know where is the problem. 我不知道问题出在哪里。 This error show up when I import my SystemCheck class to main Dart file. 当我将SystemCheck类导入到主Dart文件时,将显示此错误。

SystemCheck class: SystemCheck类:

import 'dart:io';
class SystemCheck{  
    getOperatingSystem() => Platform.operatingSystem;
    getUser() => Platform.localHostname;  
}

Import in main file: 导入主文件:

import 'cz.felguide.core/system.dart';

That's correct. 没错 You cannot use dart:io in Dartium or code designed for running in the browser. 您不能在Dartium中使用dart:io或为在浏览器中运行而设计的代码。 For this simple example much of what you want can be found in the Navigator class such as Navigator.platform 对于这个简单的示例,您可以在Navigator类中找到很多您想要的东西,例如Navigator.platform

Dart has the same limitations as Javascript in that code that is running in a browser cannot natively access the File System of the running client. Dart与Javascript具有相同的局限性,因为在浏览器中运行的代码无法本地访问正在运行的客户端的文件系统。 There are some exceptions such as the specialized Chrome Packaged Apps which allow certain permissions just within Chrome. 有一些例外情况,例如专门的Chrome打包应用程序,它们仅在Chrome中允许某些权限。 Even then they require the app to specifically request the extra permissions and the user to grant them. 即使这样,它们仍需要应用程序专门请求额外的权限,并由用户授予它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM