phone method

String? phone(
  1. String? value, {
  2. String error = 'Telefone inválido',
})

Implementation

String? phone(String? value, {String error = 'Telefone inválido'}) {
  final number = (value ?? "").replaceAll(RegExp(r'[^0-9]'), '');
  if (number.trim().length < 10) return error;
  return null;
}