#88 #74 fix: firstWhere

This commit is contained in:
lollipopkit
2023-08-04 22:53:26 +08:00
parent 0250589be2
commit ee3e30d9b5
7 changed files with 52 additions and 27 deletions

View File

@@ -47,3 +47,26 @@ List<Disk> parseDisk(String raw) {
}
return list;
}
/// Issue 88
///
/// Due to performance issues,
/// if there is no `Disk.loc == '/' || Disk.loc == '/sysroot'`,
/// return the first [Disk] of [disks].
///
/// If we find out the biggest [Disk] of [disks],
/// the fps may lower than 60.
Disk? findRootDisk(List<Disk> disks) {
if (disks.isEmpty) return null;
final roots = disks.where((element) => element.loc == '/');
if (roots.isEmpty) {
final sysRoots = disks.where((element) => element.loc == '/sysroot');
if (sysRoots.isEmpty) {
return disks.first;
} else {
return sysRoots.first;
}
} else {
return roots.first;
}
}