BeamGuard class

Checks whether current BeamLocation is allowed to be beamed to and provides steps to be executed following a failed check.

BeamGuard has an authority to change BeamerDelegate.beamingHistory. Applying the guard can have various consequences, depending on the configuration of optional properties:

See more at apply.

Constructors

BeamGuard({required List<Pattern> pathPatterns, required bool check(BuildContext context, BeamLocation<RouteInformationSerializable> location), void onCheckFailed(BuildContext context, BeamLocation<RouteInformationSerializable> location)?, BeamLocation<RouteInformationSerializable> beamTo(BuildContext context, BeamLocation<RouteInformationSerializable>? origin, BeamLocation<RouteInformationSerializable> target)?, String beamToNamed(BeamLocation<RouteInformationSerializable>? origin, BeamLocation<RouteInformationSerializable> target)?, BeamPage? showPage, bool guardNonMatching = false, bool replaceCurrentStack = true})
Creates a BeamGuard with defined properties.
const

Properties

beamTo → (BeamLocation<RouteInformationSerializable> Function(BuildContext context, BeamLocation<RouteInformationSerializable>? origin, BeamLocation<RouteInformationSerializable> target)?)
If guard check returns false, build a BeamLocation to be beamed to.
final
beamToNamed → (String Function(BeamLocation<RouteInformationSerializable>? origin, BeamLocation<RouteInformationSerializable> target)?)
If guard check returns false, beam to this URI string.
final
check bool Function(BuildContext context, BeamLocation<RouteInformationSerializable> location)
What check should be performed on a given BeamLocation, the one to which beaming has been requested.
final
guardNonMatching bool
Whether to check all the path blueprints defined in pathPatterns or check all the paths that are not in pathPatterns.
final
hashCode int
The hash code for this object.
no setterinherited
onCheckFailed → (void Function(BuildContext context, BeamLocation<RouteInformationSerializable> location)?)
Arbitrary closure to execute when check fails.
final
pathPatterns List<Pattern>
A list of path strings or regular expressions (using dart's RegExp class) that are to be guarded.
final
replaceCurrentStack bool
Whether or not to replace the current BeamLocation's stack of pages.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showPage BeamPage?
If guard check returns false, beam to a BeamLocation with just that page.
final

Methods

apply(BuildContext context, BeamerDelegate delegate, BeamLocation<RouteInformationSerializable> origin, List<BeamPage> currentPages, BeamLocation<RouteInformationSerializable> target) bool
Applies the guard. TODO add detailed comments
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldGuard(BeamLocation<RouteInformationSerializable> location) bool
Whether or not the guard should check the location.
toString() String
A string representation of this object.
inherited

Operators

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