`library utils;
//扩展list的方法
extension ExList
//扩展操作符
List
//一个链表分割成两个
List<List
}
extension Str on String {
String moneyStr() {
if (stringToDoubleEx(this) == 0) {
return '0';
}
return stringToDoubleEx(this).toStringAsFixed(2);
}
}
double stringToDoubleEx(String str) {
double num = 0;
try {
num = double.parse(str);
} catch (e) {
num = 0;
}
return num;
}
extension ExT on Object {
String toMoney() {
if (this.runtimeType == String) {
return this.toString().moneyStr();
} else if ([int, double].contains(this.runtimeType)) {
if (this != 0) {
return double.parse(this.toString()).toStringAsFixed(2);
} else {
return '0';
}
}
return '0';
}
}`