NumUtils class

create_user: zhengzaihong email:1096877329@qq.com create_date: 2024/4/12 create_time: 9:59 describe: 数字转化工具

Constructors

NumUtils.new()

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

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

base64ToBigInt(String str) BigInt?
base64ToNum(String str) num?
Base64转数字
bigIntToBase64(BigInt value) String
bigIntToString(BigInt? value, {bool withComma = false}) String
clamp(num value, num min, num max) num
限制数值范围
formatCurrency(num? value, {String symbol = '¥', int fractionDigits = 2}) String
格式化为货币(默认¥,可传入其他符号)
formatPercent(num? value, {int fractionDigits = 2}) String
格式化为百分比
formatScientific(num? value, {int fractionDigits = 2}) String
格式化为科学计数法
formatWithComma(num? value, {int fractionDigits = 2}) String
格式化为千分位(默认保留2位小数)
isNumeric(String? s) bool
是否为数字字符串
numToBase64(num value) String
数字转Base64
parse(String valueStr, {int? fractionDigits}) num?
解析字符串为数字(支持保留小数位数)
parseBigInt(String value) BigInt?
random({double min = 0, double max = 1, int fractionDigits = 2}) double
生成随机数(支持范围和小数位数)
round(num? value, int fractionDigits) num?
按指定小数位数四舍五入
safeAdd(BigInt? a, BigInt? b) BigInt
safeDivide(num a, num b, {double def = 0.0}) double
安全除法(除数为0时返回默认值)
safeDivideBigInt(BigInt? a, BigInt? b) BigInt?
safeMultiply(BigInt? a, BigInt? b) BigInt
safeSubtract(BigInt? a, BigInt? b) BigInt