canParse static method

bool canParse(
  1. String url, [
  2. String base
])

The URL.canParse() static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.

This is a fast and easy alternative to constructing a URL within a try...catch block. It returns true for the same values for which the URL() constructor would succeed, and false for the values that would cause the constructor to throw.

Implementation

external static bool canParse(
  String url, [
  String base,
]);