GuardBase class abstract

The parent class for every guard of your guard system. Extend this on an base parent class with the name of your project prefixed.

base MyProjectGuard extends GuardBase {
}

final GuardLogin extends MyProjectGuard{}

final GuardCamera extends MyProjectGuard{}
Implementers
Available extensions

Constructors

GuardBase.new({required PersistenceDelegate? persistenceDelegate})

Properties

changeNotifier Stream<bool>
A stream that could be listened to for changes in the guard's status. This stream will emit new values only when the guard's status changes, i.e., when the value emitted is different from the previous one.
no setter
checkIfSatisfied FutureOr<bool>
The function to override for indicating if the guard is satisfied or not.
no setter
currentStatus bool
The current status of the guard, whether it is satisfied or not.
no setter
guardIdentifier String
A key for identifying this guard in a key-value way
no setter
hashCode int
The hash code for this object.
no setteroverride
parentGuardSystem Guards<GuardBase>
Leave visible for eventual interaction with sibling guards or custom/complex interactions in the update method.
no setter
persistenceDelegate PersistenceDelegate?
The delegate that will be used for checking the guards. If null here, the guard system will provide the persistence delegate it has, that can also be null; in which case the guard will not persist its status.
getter/setter pair
redirectPath String
The path to redirect if the guard is not satisfied
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setUpAndInitializeGuard() Future<bool>
Define the necessary for the guard to work. The return value must declare whether the guard is satisfied or not according to that setup
toAutoRouteGuardGlobal<T extends PageRouteInfo<Object?>>(GuardedRouteGeneratingFunction<T> redirect) → AutoRouteGuard

Available on GuardBase, provided by the AutoRouteExtensionGuardBase extension

Converts your project's guard into an auto_route guard pretended to be used in the router's guards getter, globally to the whole router
toAutoRouteGuardLocal<T extends PageRouteInfo<Object?>>(GuardedRouteGeneratingFunction<T> redirect) → AutoRouteGuard

Available on GuardBase, provided by the AutoRouteExtensionGuardBase extension

Converts your project's guard into an auto_route guard pretended to be used in the router's route definition, locally to that route.
toString() String
A string representation of this object.
override
update({required bool isSatisfied}) Future<bool>
Call this function if you want to update the guard's status. This will also update the persistence delegate if it is not null.

Operators

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