Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-11-05 10:38:11 +07:00
co-authored by Claude Opus 5.5
commit 2d26ea8f90
1071 changed files with 100151 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import '../hj_utils/date_time_util.dart';
/// 可空 int 扩展
extension IntNullableX on int? {
/// 人性化数量:1234 / 1.2w / 1.3亿;0、负数、null 一律 '0'
String get countStr {
final v = this ?? 0;
if (v <= 0) return '0';
if (v < 10000) return '$v';
if (v < 100000000) return '${(v / 10000).toStringAsFixed(1)}w';
return '${(v / 100000000).toStringAsFixed(1)}亿';
}
/// 同 [countStr],但 0/null 返回 [def](按钮上显示「点赞」而不是「0」)
String countOr(String? def) => (this ?? 0) <= 0 ? (def ?? '0') : countStr;
/// 秒数 → mm:ss 或 HH:mm:ss
String get hmsStr => DateTimeUtil.formatHMS(this ?? 0);
}