File Picker is influential in Flutter and there are many ways to do that but a simple trick is Here:
Go to Pubspec.yaml
add Dependcey file_picker: ^4.6.1
Now Import the package library in File where you want to add the file picker.
import ‘package:file_picker_example/src/file_picker_demo.dart’;
If you want to Fetch a single file from devices uses this code:
FilePickerResult? result = await
FilePicker.platform.pickFiles();
if (result!= null)
{
File file = File(result.files.single.path);
}
Multiple File fetch:
FilePickerResult? result = await
FilePicker.platform.pickFiles(allowMultiple: true);
if (result != null)
{
List<File> files = result.paths.map((path) =>
File(path)).toList();
}
Comments if you Need more Help.