Template
chore: 初始化脚手架 — sunny_mochi 企业级 Flutter 模板
Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库 7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系 5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter 通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
extension NumX on num {
|
||||
/// 金额格式化:1234.5 → "1,234.50"
|
||||
String get yuan =>
|
||||
'¥${toStringAsFixed(2).replaceAllMapped(
|
||||
RegExp(r'(\d)(?=(\d{3})+\.)'),
|
||||
(m) => '${m[1]},',
|
||||
)}';
|
||||
|
||||
/// 百分比:0.75 → "75%"
|
||||
String get percent => '${(this * 100).toStringAsFixed(0)}%';
|
||||
|
||||
/// 文件大小:1024 → "1 KB"
|
||||
String get bytesFmt {
|
||||
if (this < 1024) return '$this B';
|
||||
if (this < 1024 * 1024) return '${(this / 1024).toStringAsFixed(1)} KB';
|
||||
if (this < 1024 * 1024 * 1024) {
|
||||
return '${(this / 1024 / 1024).toStringAsFixed(1)} MB';
|
||||
}
|
||||
return '${(this / 1024 / 1024 / 1024).toStringAsFixed(1)} GB';
|
||||
}
|
||||
}
|
||||
|
||||
extension NullableNumX on num? {
|
||||
String get orPlaceholder => this?.toString() ?? '-';
|
||||
}
|
||||
Reference in New Issue
Block a user