fourDigits property

String get fourDigits

4位补0

Implementation

String get fourDigits {
  int absN = this.abs();
  String sign = this < 0 ? "-" : "";
  if (absN >= 1000) return "$this";
  if (absN >= 100) return "${sign}0$absN";
  if (absN >= 10) return "${sign}00$absN";
  return "${sign}000$absN";
}