2
0
mirror of https://gitlab.com/famedly/fluffychat.git synced 2024-12-24 14:32:37 +01:00
fluffychat/lib/utils/size_string.dart
2022-07-10 09:59:47 +02:00

19 lines
488 B
Dart

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