BackButtonDispatcher class abstract

Report to a Router when the user taps the back button on platforms that support back buttons (such as Android).

When Router widgets are nested, consider using a ChildBackButtonDispatcher, passing it the parent BackButtonDispatcher, so that the back button requests get dispatched to the appropriate Router. To make this work properly, it's important that whenever a Router thinks it should get the back button messages (e.g. after the user taps inside it), it calls takePriority on its BackButtonDispatcher (or ChildBackButtonDispatcher) instance.

The class takes a single callback, which must return a Future<bool>. The callback's semantics match WidgetsBindingObserver.didPopRoute's, namely, the callback should return a future that completes to true if it can handle the pop request, and a future that completes to false otherwise.

Implementers

Constructors

BackButtonDispatcher()

Properties

hasCallbacks bool
Whether a callback is currently registered.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addCallback(ValueGetter<Future<bool>> callback) → void
Register the callback to be called when the object changes.
inherited
createChildBackButtonDispatcher() ChildBackButtonDispatcher
Creates a ChildBackButtonDispatcher that is a direct descendant of this back button dispatcher.
deferTo(ChildBackButtonDispatcher child) → void
Mark the given child as taking priority over this object and the other children.
forget(ChildBackButtonDispatcher child) → void
Causes the given child to be removed from the list of children to which this object might defer, as if deferTo had never been called for that child.
invokeCallback(Future<bool> defaultValue) Future<bool>
Handles a pop route request.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeCallback(ValueGetter<Future<bool>> callback) → void
Remove a previously registered callback.
inherited
takePriority() → void
Make this BackButtonDispatcher take priority among its peers.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited