format static method

String format(
  1. String number,
  2. CountryModel country
)

Formats number (digits only or partially typed) according to the national pattern defined for country.

  • Strips all non-digit characters first.
  • Clamps to country.maxLength digits.
  • Applies the pattern progressively as the user types.

Implementation

static String format(String number, CountryModel country) {
  final clean = _digitsOnly(number, maxLen: country.maxLength);
  if (clean.isEmpty) return '';
  return _applyPattern(clean, country.pattern);
}