Files
Regroup/lib/Utils/Common/FilePicker.dart
2024-05-23 15:43:13 +05:30

24 lines
477 B
Dart

import 'dart:io';
import 'package:file_picker/file_picker.dart';
class FilePickerMethod {
Future<File?> pickFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: [
'jpg',
'jpeg',
'png',
'pdf'
], // Define the allowed file types
);
if (result != null) {
return File(result.files.single.path!);
} else {
return null;
}
}
}