showFilePicker function
void
showFilePicker({})
Implementation
void showFilePicker({
required final Function(List<File> file) action,
final FileType fileType = FileType.image,
final bool allowMultiple = false,
final List<String>? allowedExtensions,
}) async {
final FilePickerResult? result = await FilePicker.platform.pickFiles(
type: fileType,
allowMultiple: allowMultiple,
allowedExtensions: allowedExtensions,
);
if (result != null) {
if (allowMultiple) {
final List<File> files = <File>[];
for (var i in result.files) {
if (i.path != null) files.add(File(i.path!));
}
} else {
final File file = File(result.files.single.path!);
action(<File>[file]);
}
}
}