mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: shell_func only get useful mem data
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
class Memory {
|
||||
final int total;
|
||||
final int free;
|
||||
final int cache;
|
||||
final int avail;
|
||||
|
||||
const Memory({
|
||||
required this.total,
|
||||
required this.free,
|
||||
required this.cache,
|
||||
required this.avail,
|
||||
});
|
||||
|
||||
@@ -46,16 +44,6 @@ Memory parseMem(String raw) {
|
||||
'0',
|
||||
) ??
|
||||
0;
|
||||
final cached = int.tryParse(
|
||||
items
|
||||
.firstWhere(
|
||||
(e) => e?.group(1) == 'Cached:',
|
||||
orElse: () => null,
|
||||
)
|
||||
?.group(2) ??
|
||||
'0',
|
||||
) ??
|
||||
0;
|
||||
final available = int.tryParse(
|
||||
items
|
||||
.firstWhere(
|
||||
@@ -70,7 +58,6 @@ Memory parseMem(String raw) {
|
||||
return Memory(
|
||||
total: total,
|
||||
free: free,
|
||||
cache: cached,
|
||||
avail: available,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@ enum SystemType {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool isSegmentsLenMatch(int len) {
|
||||
bool isSegmentsLenMatch(int len) => len == segmentsLen;
|
||||
|
||||
int get segmentsLen {
|
||||
switch (this) {
|
||||
case SystemType.linux:
|
||||
return len == StatusCmdType.values.length;
|
||||
return StatusCmdType.values.length;
|
||||
case SystemType.bsd:
|
||||
return len == BSDStatusCmdType.values.length;
|
||||
return BSDStatusCmdType.values.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user