showMaterialFilePicker function
Future<void>
showMaterialFilePicker({
- BuildContext? context,
- FileType fileType = FileType.any,
- List<
String> ? allowedExtensions, - ValueChanged<
PlatformFile> ? onChanged,
Allows selection of a file.
Implementation
Future<void> showMaterialFilePicker({
BuildContext? context,
FileType fileType = FileType.any,
List<String>? allowedExtensions,
ValueChanged<PlatformFile>? onChanged,
}) async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: fileType,
withData: true,
allowMultiple: false,
allowedExtensions: allowedExtensions,
);
if (result != null && result.files.length == 1) {
PlatformFile file = result.files.single;
if (onChanged != null) onChanged(file);
}
}