feat: appbar
This commit is contained in:
@@ -5,21 +5,31 @@ abstract final class SizeConstants {
|
||||
const SizeConstants._();
|
||||
|
||||
static const s = 8.0;
|
||||
static const xs = 11.0;
|
||||
static const xxs = 14.0;
|
||||
static const m = 16.0;
|
||||
static const xm = 25.0;
|
||||
static const xm = 20.0;
|
||||
static const xxm = 25.0;
|
||||
static const l = 32.0;
|
||||
static const xl = 64.0;
|
||||
static const xl = 48.0;
|
||||
static const xxl = 64.0;
|
||||
}
|
||||
|
||||
abstract final class RatioConstants {
|
||||
const RatioConstants._();
|
||||
|
||||
// 0.75
|
||||
static const threeFourth = 3 / 4;
|
||||
// 0.6
|
||||
static const twoThird = 2 / 3;
|
||||
// 0.5
|
||||
static const oneHalf = 1 / 2;
|
||||
static const half = 1 / 2;
|
||||
// 0.3
|
||||
static const oneThird = 1 / 3;
|
||||
// 0.25
|
||||
static const quarter = 1 / 4;
|
||||
// 0.15
|
||||
static const halfQuarter = 3 / 20;
|
||||
// 0.10
|
||||
static const oneTenth = 1 / 10;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user