24 lines
483 B
Dart
24 lines
483 B
Dart
import 'dart:io';
|
|
|
|
import 'package:file_picker/file_picker.dart';
|
|
|
|
class SingleFilePickerMethod {
|
|
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;
|
|
}
|
|
}
|
|
}
|