# Url constructor

Url(

1. String spec

)

Represents a Uniform Resource Locator (URL) and provides methods to parse, construct, and open connections to the referenced resource.

This class acts as a convenient wrapper around Dart's built-in Uri class, and integrates with JetLeaf's networking system to provide typed access and connection management.

Use Url when you need structured access to URL components or want to establish a connection via UrlConnection.

### Example: Parse and connect

    final url = Url('https://example.com/api/data?user=42');
    print(url.host);     // example.com
    print(url.query);    // user=42

    final stream = await url.openStream();
    int byte;
    while ((byte = await stream.readByte()) != -1) {
      print(String.fromCharCode(byte));
    }
    await stream.close();

Parses the given `spec` string into a Url instance.

Throws a MalformedUrlException if the URL is not valid.

## Implementation

    Url(String spec) : _uri = _parseUri(spec);