url method
FormFieldValidator
that requires the field's value to be a valid url.
Implementation
static FormFieldValidator url(
{String errorText = "This field requires a valid URL address.",
List<String> protocols = const ['http', 'https', 'ftp'],
bool requireTld = true,
bool requireProtocol = false,
bool allowUnderscore = false,
List<String> hostWhitelist = const [],
List<String> hostBlacklist = const []}) {
return (valueCandidate) {
if (valueCandidate != null && valueCandidate.isNotEmpty) {
if (!isURL(valueCandidate,
protocols: protocols,
requireTld: requireTld,
requireProtocol: requireProtocol,
allowUnderscore: allowUnderscore,
hostWhitelist: hostWhitelist,
hostBlacklist: hostBlacklist)) return errorText;
}
};
}