url static method
Validates URL format
Example:
Validators.url('https://example.com');
Implementation
static String? url(String? value, {String? message}) {
if (value == null || value.isEmpty) return null;
try {
final uri = Uri.parse(value);
if (!uri.hasScheme || (uri.scheme != 'http' && uri.scheme != 'https')) {
return message ?? 'Please enter a valid URL';
}
return null;
} catch (_) {
return message ?? 'Please enter a valid URL';
}
}