QueryString
The query string of the current page route, available as Page.query.
It is parsed from Page.route on every access, so it can be read
in main() as well as in a Page.on_route_change handler. For
example, with the route /products?id=1&sort=price:
page.query.get("id")returns"1";page.query.to_dictreturns{"id": "1", "sort": "price"};page.query.pathreturns"/products".
Values are always strings. To navigate to a route with a query string, pass
the parameters as keyword arguments to Page.navigate or
Page.push_route.
Inherits: flet.controls.query_string.UrlComponents
Properties
Methods
Properties
pathproperty
path: strReturn the path component of the current page route, without the query string and fragment.
to_dictproperty
to_dict: dictParse the query component of the current page route into a dictionary.
The route is read on every access, so the result always matches
Page.route. Keys and values are percent-decoded, with +
decoded as a space. Parameters without a value, such as debug in
?debug or ?debug=, are left out. When a key appears more than once,
its last non-empty value is returned.
Methods
get
get(key: str) -> strReturn the value of the query parameter key in the current page route.
Parameters:
- key (str) - The name of the query parameter.
Returns:
- str - The decoded value. When
keyappears more than once, its last non-empty value.
Raises:
- KeyError - If the route has no query parameter
keywith a non-empty value.
post
post(kwargs: dict)Build an encoded querystring from key-value pairs.
Returns:
- A querystring that starts with
?and is ready to append to a URL.