void routeChanged(
bool visible,
List<String> params,
bool visibilityChanged
)

Implement this callback in your element.

It will be invoked each time when: your element is invisible and should become visible your element is visible and should become invisible your element is visible, should stay visible, but params changed (see routerParams) your element is visible, should stay visible, but route changed

Use argument visibilityChanged to decide whether your visibility actually changed, or you are just being notified about some other change.

if (visible && visibilityChanged) {
  doSomeExpensiveLoadingStuff();
}
if (!visible && visibilityChanged) {
  cancelAllTasks();
}

Source

/// Implement this callback in your element.
///
/// It will be invoked each time when:
/// * your element is invisible and should become visible
/// * your element is visible and should become invisible
/// * your element is visible, should stay visible, but params changed (see [routerParams])
/// * your element is visible, should stay visible, but route changed
///
/// Use argument `visibilityChanged` to decide whether your visibility actually changed,
/// or you are just being notified about some other change.
///
///     if (visible && visibilityChanged) {
///       doSomeExpensiveLoadingStuff();
///     }
///     if (!visible && visibilityChanged) {
///       cancelAllTasks();
///     }
///
void routeChanged(bool visible, List<String> params, bool visibilityChanged);