query top-level property

Parser<List<(String, String?)>> query
final

A parser that decomposes a URI query string into a list of key-value pairs.

Accepts input formatted as {key[=value]}&... and returns a list of records with positional fields ($1: key, $2: value?).

For example:

final result = query.parse('foo=1&bar=&baz');
print(result.value); // [('foo', '1'), ('bar', ''), ('baz', null)]

Implementation

final query = _param
    .plusSeparated('&'.toParser())
    .map(
      (list) => list.elements
          .where((each) => each.$1.isNotEmpty || each.$2 != null)
          .toList(),
    );