Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter dart:io或dart:html的条件导入_Flutter_File_Flutter Web - Fatal编程技术网

Flutter dart:io或dart:html的条件导入

Flutter dart:io或dart:html的条件导入,flutter,file,flutter-web,Flutter,File,Flutter Web,我需要使用文件类,这在web和html中是不同的(正如我所理解的) 我希望能够做到 import if (dart.library.io) 'dart:io' if (dart.library.io) 'dart:html'; 但这不起作用 从移动应用程序上的dart:io和web上的dart:html读取文件的解决方案是什么 谢谢你这个包裹可以帮你。也可以使用条件导入,如: import 'dart:io' if (dart.library.html) 'dart:html'; 您可以导入

我需要使用文件类,这在web和html中是不同的(正如我所理解的)

我希望能够做到

import if (dart.library.io) 'dart:io' if (dart.library.io) 'dart:html';
但这不起作用

从移动应用程序上的dart:io和web上的dart:html读取文件的解决方案是什么

谢谢你

这个包裹可以帮你。也可以使用条件导入,如:

import 'dart:io' if (dart.library.html) 'dart:html';

您可以导入带有“as”关键字的两个包,如dart:io作为dart\u io和dart\u html作为dart\u html,然后根据您在不同平台上的要求使用这些别名调用函数