Url class

URL Validator.

Blank field - null value - is a valid input!

If the URL is required, see ReqUrl or Req.

Notes on possible differences from a standard/generic validation:

  • utf-8 char class take in consideration the full Unicode range

  • Top-level domains (TLDs) have been made mandatory so single names like "localhost" fails

  • protocols have been restricted to ftp, http and https

  • IP address dotted notation validation, range: 1.0.0.0 - 223.255.255.255 first and last IP address of each class is considered invalid (since they are broadcast/network addresses)

  • Made starting path slash optional (http://example.com?foo=bar)

  • Allow a dot (.) at the end of hostnames (http://example.com.)

  • Allow an underscore (_) character in host/domain_names

  • Check dot delimited parts length and total length

  • Made protocol optional, allowed short syntax //

Constructors

Url({String mal = 'malformed URL'})
Validates URL values using a regular expression.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
mal String
The error message in case of a malformed URL value.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(String? value) String?
Returns null if value is null or a valid URL; returns mal otherwise.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

urlPattern RegExp
A suitable pattern for URL values.
final