isUrl property
bool
get
isUrl
Returns true if this is a valid url.
Example:
final text = 'https://example.com';
final isUrl = text.isUrl;
// returns: true
Implementation
bool get isUrl => RegExp(
r'^(?:(?:https?|ftp):\/\/)?' // optional scheme
r'(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}' // domain
r'(?::\d{1,5})?' // optional port
r'(?:[/?#][^\s]*)?$', // optional path, query, or fragment
caseSensitive: false,
).hasMatch(trim());