hunnichat/lib/utils/size_string.dart
mowetentertainment1 8ee77e3548
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
12/6/2025
2025-12-06 12:46:34 -05:00

22 lines
562 B
Dart

extension SizeString on num {
String get sizeString {
var size = toDouble();
if (size < 1000) {
return '${size.round()} Bytes';
}
if (size < 1000 * 1000) {
size = size / 1000;
size = (size * 10).round() / 10;
return '${size.toString()} KB';
}
if (size < 1000 * 1000 * 1000) {
size = size / 1000000;
size = (size * 10).round() / 10;
return '${size.toString()} MB';
}
size = size / 1000 * 1000 * 1000 * 1000;
size = (size * 10).round() / 10;
return '${size.toString()} GB';
}
}