onChange static method
void
onChange(})
Listen to changes in the query string.
The callback
function will be called whenever the query string changes.
The immediate
parameter is used to determine if the callback should be called immediately.
The runOnce
parameter is used to determine if the callback should be called only once.
Implementation
static void onChange(
Function(Map<String, String>) callback, {
bool? immediate = false,
bool? runOnce = false,
}) {
_controller.stream.listen((data) {
if (immediate!) {
callback(data);
} else {
// delay the callback to allow the query string to be updated
Future.delayed(Duration(milliseconds: 100), () {
callback(data);
});
}
if (runOnce!) {
_controller.close();
}
callback(data);
});
}