show img size

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-05-16 17:23:09 +08:00
parent 0c60800b36
commit 88b7f82406
22 changed files with 122 additions and 38 deletions

View File

@@ -1,5 +1,20 @@
import 'dart:math' show pow;
const unitArr = ['B', 'K', 'M', 'G', 'T', 'P'];
extension NumExt on num {
String get formatSize {
var value = this;
int index = 0;
while (value >= 1024) {
index++;
value = value / 1024;
}
String size = value.toStringAsFixed(2);
return size + (unitArr.elementAtOrNull(index) ?? '');
}
}
extension IntExt on int? {
int? operator +(int other) => this == null ? null : this! + other;
int? operator -(int other) => this == null ? null : this! - other;