description

# tryParse static method

Uri? tryParse(

1. String uri, [
2. int start = 0,
3. int? end

])

Creates a new `Uri` object by parsing a URI string.

If `start` and `end` are provided, they must specify a valid substring of `uri`, and only the substring from `start` to `end` is parsed as a URI.

Returns `null` if the `uri` string is not valid as a URI or URI reference.

Example:

    final uri = Uri.tryParse(
        'https://dart.dev/libraries/dart-core#utility-classes', 0, 16);
    print(uri); // https://dart.dev

    var notUri = Uri.tryParse('::Not valid URI::');
    print(notUri); // null

## Implementation

    static Uri? tryParse(String uri, [int start = 0, int? end]) {
      // TODO: Optimize to avoid throwing-and-recatching.
      try {
        return parse(uri, start, end);
      } on FormatException {
        return null;
      }
    }