flutter_file_picker
8.0.6

Um pacote que permite usar o explorador de arquivos nativo para escolher arquivos únicos ou múltiplos, com o suporte de filtragem de extensões.
Uint8List ), se necessário;Se você tiver algum recurso que deseja ver neste pacote, sinta -se à vontade para emitir uma sugestão. ?
| API | Android | iOS | Linux | macos | Windows | Web |
|---|---|---|---|---|---|---|
| ClearTemporaryFiles () | ✔️ | ✔️ | ||||
| getDirectoryPath () | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| pickfiles () | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| savefile () | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Consulte a seção API do Wiki do seletor de arquivos ou a referência oficial da API no Pub.Dev para obter mais detalhes.
Consulte o Wiki do seletor de arquivos para obter todos os detalhes sobre como instalar, configurá -lo e usá -lo.
Exemplo de uso simples rápido:
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);
}Para detalhes de uso total, consulte o wiki acima.





Para obter ajuda para começar a Flutter, veja nossa documentação on -line.
Para obter ajuda na edição do código do plug -in, visualize a documentação.