【发布时间】:2020-09-07 23:25:22
【问题描述】:
【问题讨论】:
-
请提供更多信息以提供帮助,并记住将带有错误日志的代码 sn-p 作为文本而不是屏幕截图发布。
-
这能回答你的问题吗? How to get the file selected
标签: flutter flutter-web
【问题讨论】:
标签: flutter flutter-web
您需要获取数据并为其创建一个 MediaInfo 类
class MediaInfo{
String fileName;
String filePath;
}
获取文件路径
Future<MediaInfo> convertFileGetNamePath({@required html.File file}) async {
final Map<String, dynamic> infoData = {};
final reader = html.FileReader();
reader.readAsDataUrl(file);
await reader.onLoad.first;
final fileName = file.name;
infoData.addAll({
'name': fileName,
'path': filePath,
});
MediaInfo webImageInfo = MediaInfo();
webImageInfo.fileName = infoData['name'];
webImageInfo.filePath = infoData['path'];
return webImageInfo;
}
在你的代码中实现它
MediaInfo getInfo = await convertFileGetNamePath(file: imageFile);
fileName = getInfo.fileName;
【讨论】: