listFiles function
Implementation
List<String?> listFiles(String path,
[bool recursive = false, bool allFiles = false]) {
final files = <String?>[];
try {
var dir = Directory(path);
final dartFile = allFiles ? Glob('**') : Glob('**.dart');
List contents = dir.listSync(recursive: recursive);
for (var fileOrDir in contents) {
if (dartFile.matches(fileOrDir.path)) {
files.add(fileOrDir.path);
}
}
} catch (e) {
print('Exception while listing files: $e');
}
files.sort();
return files;
}