getImageFilesFromFolder static method
Implementation
static Future<List<File>> getImageFilesFromFolder(String folderPath) async {
final directory = Directory(folderPath);
if (!await directory.exists()) {
throw Exception('Directory does not exist');
}
final imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.heic', '.webp'];
final imageFiles =
directory
.listSync()
.whereType<File>()
.where((file) => imageExtensions.contains(p.extension(file.path).toLowerCase()))
.toList();
return imageFiles;
}