validateURL method

bool validateURL()

Validates whether the String is a valid URL.

This method uses a regular expression defined in RegExpPatterns.url to check if the string matches a valid URL format.

Returns true if the string is a valid URL, otherwise returns false.

Example:

String? url = "https://www.example.com";
print(url.validateURL()); // true

String? invalidUrl = "invalid-url";
print(invalidUrl.validateURL()); // false

Implementation

bool validateURL() => hasMatch(this, RegExpPatterns.url);