findFolderByName function

Directory? findFolderByName(
  1. String root,
  2. String name
)

find a folder from the name in the lib folder

Implementation

Directory? findFolderByName(String root, String name) {
  var current = Directory(root);
  final list = current.listSync(recursive: true, followLinks: false);
  final contains = list.firstWhere((element) {
    if (element is Directory) {
      return element.path.contains(name);
    }
    return false;
  });
  return contains as Directory?;
}