params method

HttpRequest params(
  1. Map<String, dynamic> params
)

Adds query parameters to the request URL.

Parameters are URL-encoded and appended to the existing query string. Existing parameters with the same keys will be overwritten.

params Map of parameter names to values.

Returns this HttpRequest for method chaining.

Example

request.params({'limit': 10, 'filter': 'active'});

Implementation

HttpRequest params(Map<String, dynamic> params) {
  _url = _url.replace(
    queryParameters: Map<String, dynamic>.from(_url.queryParameters)
      ..addAll(params.map((key, value) => MapEntry(key, value.toString()))),
  );
  return this;
}