getDocuments method
Implementation
@override
Future<List<DocumentFile>> getDocuments({
int? limit,
int? offset,
List<String>? typeFilters,
String? sortBy,
String? sortOrder,
}) async {
try {
final List<dynamic>? result = await methodChannel
.invokeMethod('getDocuments', {
'limit': limit,
'offset': offset,
'mimeTypes': typeFilters,
'sortColumn': sortBy,
'sortOrder': sortOrder,
});
if (result != null) {
return result
.map((item) => DocumentFile.fromMap(item as Map<Object?, Object?>))
.toList();
}
return [];
} on PlatformException catch (e) {
// Catch our custom Java error codes!
if (e.code == 'PERMISSION_DENIED') {
throw Exception(
'Storage Permission Denied: You must request storage permissions '
'before calling getDocuments().',
);
} else if (e.code == 'QUERY_ERROR') {
throw Exception('Native MediaStore Query Failed: ${e.message}');
} else {
throw Exception('Unknown native error: ${e.message}');
}
}
}