format method
Formats value into a display string.
Implementation
@override
String format(num value) {
final integer = _checkedInteger(value, 'Must be a finite integer.');
if (integer == 0) return _digits[0];
if (integer < 0) return '마이너스${format(-integer)}';
final sections = <int>[];
var rest = integer;
while (rest > 0) {
sections.add(rest % 10000);
rest ~/= 10000;
}
if (sections.length > _sectionUnits.length) {
throw ArgumentError.value(
value,
'value',
'Exceeds supported Korean section units.',
);
}
final buffer = StringBuffer();
for (var index = sections.length - 1; index >= 0; index -= 1) {
final section = sections[index];
if (section == 0) continue;
final omitOneBeforeSectionUnit =
buffer.isEmpty && index == 1 && section == 1;
if (!omitOneBeforeSectionUnit) {
buffer.write(_formatSection(section));
}
buffer.write(_sectionUnits[index]);
}
return buffer.toString();
}