pickFile static method
Picks a file based on the specified fileType
and optional customType
.
Returns the file path of the picked file.
Throws a PlatformException if the operation fails.
Implementation
static Future<String?> pickFile({
required FileType fileType,
List<String>? customType,
}) async {
const MethodChannel channel = MethodChannel('MediaPicker');
try {
var filePath = await channel.invokeMethod('pickMedia', {
'mediaType': "File",
'pickerType': fileType.toString().split('.').last,
'options': {"fileTypes": customType},
});
return filePath;
} catch (e) {
// Handle platform-specific exceptions if needed
print('Error picking file: $e');
rethrow;
}
}