formatContactNumber static method
Formats contact numbers, normalising '+61' to '0' and spacing 10-digit numbers.
Implementation
static String formatContactNumber(String? phone) {
if (phone == null || phone.isEmpty) {
return "";
}
var cleaned = phone.replaceFirst(RegExp(r'^\+61'), '0').replaceAll(RegExp(r'\D'), '');
if (cleaned.length == 10) {
return "${cleaned.substring(0, 4)} ${cleaned.substring(4, 6)} ${cleaned.substring(6)}";
}
return cleaned;
}