validateWebLink method

String? validateWebLink(
  1. String? value
)

Implementation

String? validateWebLink(String? value) {
  if (value!.isEmpty) {
    return null;
  } else {
    var regex = RegExp(
        r"((https?:www\.)|(https?:\/\/)|(www\.))?[\w\-?=%.][-a-zA-Z0-9@:%.\+~#=]{1,256}\.[a-zA-Z0-9]{1,6}(\/[-a-zA-Z0-9()@:%\+.~#?&\/=]*)?");
    var matchRegex = regex.hasMatch(value);
    if (matchRegex) {
      return null;
    } else {
      return 'Enter a valid web-link';
    }
  }
}