mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
15 lines
383 B
Dart
15 lines
383 B
Dart
|
|
||
|
String formatBytes(int bytes) {
|
||
|
if (bytes < 1000) {
|
||
|
return "$bytes B";
|
||
|
} else if (bytes < 1000000) {
|
||
|
final kb = (bytes / 1000).toStringAsFixed(1);
|
||
|
return "$kb kB";
|
||
|
} else if (bytes < 1000000000) {
|
||
|
final mb = (bytes / 1000000).toStringAsFixed(1);
|
||
|
return "$mb MB";
|
||
|
} else {
|
||
|
final gb = (bytes / 1000000000).toStringAsFixed(1);
|
||
|
return "$gb GB";
|
||
|
}
|
||
|
}
|