feat: appbar

This commit is contained in:
shenlong-tanwen
2024-10-27 23:43:58 +05:30
parent 5385d43c8c
commit 8450c8cc4f
40 changed files with 1150 additions and 211 deletions
@@ -0,0 +1,24 @@
import 'dart:math';
extension NumberToSizeExtension on num {
String formatAsSize({int noOfDecimals = 0}) {
const List<String> units = [
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
];
if (this == 0) return '0 B';
final index = (log(this) / log(1024)).floor();
final byteIndex = index.clamp(0, units.length - 1);
final size = (this / pow(1024, byteIndex)).round();
// ignore: avoid-unsafe-collection-methods
return '${size.toStringAsFixed(noOfDecimals)} ${units[byteIndex]}';
}
}
@@ -1,3 +1,4 @@
extension StringNumberUtils on String {
int? tryParseInt() => int.tryParse(this);
int parseInt() => int.parse(this);
}