2022-08-26 19:28:01 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
2022-08-24 05:35:49 +00:00
|
|
|
class DiskSize {
|
|
|
|
DiskSize({final this.byte = 0});
|
|
|
|
|
2022-08-26 19:28:01 +00:00
|
|
|
int byte;
|
|
|
|
|
2022-08-26 16:46:30 +00:00
|
|
|
double asKb() => byte / 1024.0;
|
|
|
|
double asMb() => byte / 1024.0 / 1024.0;
|
|
|
|
double asGb() => byte / 1024.0 / 1024.0 / 1024.0;
|
2022-08-24 05:35:49 +00:00
|
|
|
|
2022-08-26 19:28:01 +00:00
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
if (byte < 1024) {
|
|
|
|
return '${byte.toStringAsFixed(0)} ${tr('bytes')}';
|
|
|
|
} else if (byte < 1024 * 1024) {
|
|
|
|
return 'providers.storage.kb'.tr(args: [asKb().toStringAsFixed(1)]);
|
|
|
|
} else if (byte < 1024 * 1024 * 1024) {
|
|
|
|
return 'providers.storage.mb'.tr(args: [asMb().toStringAsFixed(1)]);
|
|
|
|
} else {
|
|
|
|
return 'providers.storage.gb'.tr(args: [asGb().toStringAsFixed(1)]);
|
|
|
|
}
|
|
|
|
}
|
2022-08-24 05:35:49 +00:00
|
|
|
}
|