UrlBuilder class

This class is a helper for URL path manipulations. It provides a way to keep the base url, then add a request path to it and apply some query and path params to it. Here is the example usage of it.

UrlBuilder get baseUrl => UrlBuilder.base('https://example.com');

final requestUrl = baseUrl
              .url('users/{userId}/documents/{documentId}')
              .addPath('userId', '123')
              .addPath('documentId', '456')
              .addQuery('type', 'education')
              .addQuery('name', 'calculus')
              .toString()

The value of requestUrl will be
https://example.com/users/123/documents/456?type=education&name=calculus

Constructors

UrlBuilder.base(String base)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addPath(String name, Object value) UrlBuilder
addQuery(String name, Object value) UrlBuilder
addQueryArray(String name, List<Object> values) UrlBuilder
addUrlEntry(UrlEntry entry) UrlBuilder
addUrlEntryHandler(UrlEntryHandler<UrlEntry> handler) UrlBuilder
base(String base) → _HttpRestUrlBuilder
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
url(String url) UrlBuilder

Operators

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