update method

void update(
  1. Map<String, Object?> values, {
  2. bool push = false,
  3. Object? state,
})

Updates multiple query parameters and writes the updated URL.

null values remove their keys. Iterable values become repeated query values.

Implementation

void update(Map<String, Object?> values, {bool push = false, Object? state}) {
  final next = Map<String, dynamic>.from(_uri.queryParameters);

  for (final entry in values.entries) {
    final value = entry.value;
    if (value == null) {
      next.remove(entry.key);
    } else if (value is Iterable) {
      next[entry.key] = value.map((item) => item.toString()).toList();
    } else {
      next[entry.key] = value.toString();
    }
  }

  _write(next, push: push, state: state);
}