# Url class final

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();

## Constructors

Url.new(String spec)
  Represents a Uniform Resource Locator (URL) and provides methods to parse, construct, and open connections to the referenced resource.
Url.fromComponents({required String protocol, required String host, int port = -1, String path = '', String query = '', String fragment = ''})
  Creates a new Url instance from its individual components.

## Properties

fragment → String
  The fragment (e.g., `"section1"`) without leading `'#'`.
  no setter
hashCode → int
  The hash code for this object.
  no setter override
host → String
  The host portion of the URL (e.g., `"example.com"`).
  no setter
path → String
  The path component of the URL (e.g., `"/api/data"`).
  no setter
port → int
  The port number, or `-1` if not explicitly set.
  no setter
protocol → String
  The scheme of the URL, such as `"http"` or `"https"`.
  no setter
query → String
  The query string (e.g., `"name=foo&age=30"`) without leading `'?'`.
  no setter
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited

## Methods

noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
openConnection() → UrlConnection
  Opens a new UrlConnection to the resource represented by this Url.
openStream() → Future<InputStream>
  Opens a connection to this Url and returns an InputStream to read from it.
toString() → String
  A string representation of this object.
  override
toUri() → Uri
  Returns this Url as a Uri.

## Operators

operator ==(Object other) → bool
  The equality operator.
  override