validator method

String? validator(
  1. String? phoneNumber
)

Implementation

String? validator(String? phoneNumber) {
  if (phoneNumber == null || phoneNumber.isEmpty) {
    _isValid = false;
    return _errorText ?? 'الرجاء إدخال رقم الجوال';
  } else {
    try {
      final englishNumber = arabicNumberConverter(phoneNumber);
      final phoneInfo =
          getPhoneNumberInfo('${_selectedCountry.dialCode}$englishNumber');
      final isValid = phoneInfo.validate();
      _isValid = isValid;
      if (!isValid) {
        return _errorText ?? "الرجاء ادخال رقم جوال صحيح";
      }
      return null;
    } catch (e) {
      debugPrint(e.toString());
      return null;
    }
  }
}