formatInt static method
解析数字,转化为两位数,不足补0
num
数字
digit
保留位数,默认保留2位数
locale
地域
解析结果:1 -> 01
Implementation
static String formatInt(
int num, [
int digit = 2,
String locale = 'en_US',
]) {
String pattern = '0' * digit;
NumberFormat format = NumberFormat(pattern, locale);
return format.format(num);
}