You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
488 B
Dart
19 lines
488 B
Dart
3 years ago
|
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';
|
||
|
}
|
||
|
}
|
||
|
}
|