parsePhone function

String parsePhone(
  1. String phone
)

parsePhone will try to convert phone number in required format. A full chat id (...@c.us, ...@g.us, ...@newsletter, ...@lid) is passed through unchanged, so groups and channels can be sent to with the same methods.

Implementation

String parsePhone(String phone) {
  final trimmed = phone.trim();
  if (trimmed.contains("@")) return trimmed;
  return "${_digits(trimmed)}@c.us";
}