HbUtil class
Properties
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
Static Methods
-
addPercent(String? num, {bool needOperate = false})
→ String
-
增加百分号,并加上正负符号
needOperate 是否需要加上正负号,默认不需要
-
addressFormat(String? address, {String slot = '.', int digit = 6})
→ String
-
将地址缩短为前几位和后几位,中间用点号替代
返回格式 0x912C...9E6548
address 需要格式化的地址
slot 中间替代符号,默认为点号
digit 前后保留的位数,默认为6
-
copy(String? text)
→ Future<void>
-
复制字符串到剪切板
-
dateTimeFormat(BuildContext context, {required Object? time, FormatFn? customFormat, HmsFormat? hmsAddFormat})
→ String
-
日期格式化: 且会根据不同国家显示不同的样式
默认格式:2023/10/06 12:56:34
customFormat格式是:日期格式化,DateFormat.yMd,DateFormat.Md,DateFormat.yMMMMd
hmsAddFormat: 添加时分秒的格式化样式
time,可以是 DateTime类型,String,int类型为时间戳
-
formatEthAddress(dynamic address)
→ dynamic
-
-
formatNum(String? num, {int digit = 6, bool needThousands = true, dynamic remainAvailable = false, dynamic showBracket = false})
→ String
-
取小数点后几位-截断保留
@param num 数值
@param location 保留几位小数
@param needThousands 是否需要千位分割。默认需要
@param remainAvailable 是否计算有效小数。默认不计算,比如0.0003,小数位是2位,true返回0.0003,false返回0
@param showBracket 小数多0是否展示括号
-
generateRandomString({int length = 8})
→ String
-
生成随机字符串
-
isPositive(String? num)
→ bool
-
是否为正
-
isSameDay(DateTime date1, DateTime date2)
→ bool
-
判断两个 DateTime 是否是同一天
-
thousands(String integerStr)
→ String
-
整数增加千位分割符,接收一个整数字符串参数
-
toScientific(String? num)
→ String
-
交易量科学计数
-
web3ErrorFormat(String input)
→ String
-
链上错误消息格式化