flutter_file_picker
8.0.6

允许您使用本机文件资源管理器选择单个或多个文件的软件包,并具有扩展滤波支持。
Uint8List )中;如果您有任何要在此软件包中看到的功能,请随时发出建议。 ?
| API | 安卓 | ios | Linux | macos | 视窗 | 网络 |
|---|---|---|---|---|---|---|
| clearTemporaryFiles() | ✔️ | ✔️ | ||||
| getDirectoryPath() | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| pickfiles() | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| savefile() | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
有关更多详细信息,请参见文件选择器Wiki的API部分或Pub.Dev上的官方API参考。
有关如何安装,设置和使用它的每个详细信息,请参见文件选择器Wiki 。
快速简单用法示例:
FilePickerResult ? result = await FilePicker .platform. pickFiles ();
if (result != null ) {
File file = File (result.files.single.path ! );
} else {
// User canceled the picker
} FilePickerResult ? result = await FilePicker .platform. pickFiles (allowMultiple : true );
if (result != null ) {
List < File > files = result.paths. map ((path) => File (path ! )). toList ();
} else {
// User canceled the picker
} FilePickerResult ? result = await FilePicker .platform. pickFiles (
allowMultiple : true ,
type : FileType .custom,
allowedExtensions : [ 'jpg' , 'pdf' , 'doc' ],
); String ? selectedDirectory = await FilePicker .platform. getDirectoryPath ();
if (selectedDirectory == null ) {
// User canceled the picker
} String ? outputFile = await FilePicker .platform. saveFile (
dialogTitle : 'Please select an output file:' ,
fileName : 'output-file.pdf' ,
);
if (outputFile == null ) {
// User canceled the picker
} FilePickerResult ? result = await FilePicker .platform. pickFiles ();
if (result != null ) {
PlatformFile file = result.files.first;
print (file.name);
print (file.bytes);
print (file.size);
print (file. extension );
print (file.path);
} else {
// User canceled the picker
} FilePickerResult ? result = await FilePicker .platform. pickFiles ();
if (result != null ) {
// All files
List < XFile > xFiles = result.xFiles;
// Individually
XFile xFile = result.files.first.xFile;
} else {
// User canceled the picker
} FilePickerResult ? result = await FilePicker .platform. pickFiles ();
if (result != null ) {
Uint8List fileBytes = result.files.first.bytes;
String fileName = result.files.first.name;
// Upload file
await FirebaseStorage .instance. ref ( 'uploads/$ fileName ' ). putData (fileBytes);
}有关完整的用法详细信息,请参阅上面的Wiki 。





如需帮助开始进行扑朔迷离,请查看我们的在线文档。
有关编辑插件代码的帮助,请查看文档。