toFormatString method

String toFormatString({
  1. String format = "#.##",
})

金额格式化

Implementation

String toFormatString({String format = "#.##"}) {
  if (this.isEmptyString) {
    return this;
  }
  String regex = "^((([0-9]+|0).([0-9]{1,2}))\$)|^(([1-9]+).([0-9]{1,2})\$)";
  if (RegExp(regex).hasMatch(this)) {
    final oCcy = new NumberFormat(format);
    return oCcy.format(this.toNumDouble);
  } else {
    return this;
  }
}