In order to use this plugin, add dependency in the pubspec.yaml
:
file_selector:
git:
url: https://github.com/marchdev-tk/file_selector
Add an import to dart file:
import 'package:file_selector/file_selector.dart';
Web sample:
Desktop sample:
Mobile sample:
final File file = await FileSelector().pickFile(
type: FileType.img,
confirmButtonText: 'Select',
);
where:
-
confirmButtonText
(works only onDesktop
) if set, changes default confirmation text on file picker popup; -
type
represents the group of required types of specific type, could be one of the following:any
or*/*
img
orimage/*
png
orimage/png
jpg
orimage/jpeg
gif
orimage/gif
bmp
orimage/bmp
pdf
orapplication/pdf
final List<File> files = await FileSelector().pickFiles(
types: [FileType.png, FileType.bmp],
confirmButtonText: 'Select',
);
The only difference of pickFiles
method from pickFile
is that multiple files could be selected same as multiple types
.
name
of the filepath
to the file, for Web it is emptybytes
array of bytes
Feel free to post a feature requests or report a bug here.