PreconditionsRepository class Null safety

Repository of all preconditions of your app. You will typically need just one singleton instance of PreconditionsRepository. It is a mutable ChangeNotifier, which you can integrate with all sort of state management tools.

See package README for usage example.

Inheritance

Constructors

PreconditionsRepository()

Properties

hashCode int
The hash code for this object.
read-onlyinherited
hasListeners bool
Whether any listeners are currently registered.
@protectedread-onlyinherited
isEvaluating bool
Use this flag to render CircularProgressIndicator or similar feedback to user.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
debugPrecondition(PreconditionId id, [Map<PreconditionId, bool>? _doneMap]) → void
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
@mustCallSuperinherited
evaluatePrecondition(Precondition p, {bool ignoreCache = false}) Future<Precondition>
Runs single precondition test. If the test is already running it won't be started again and you will receive the result of already running evaluation. If the test has dependencies, they will be evaluated first. If they fail, your test won't be run at all and it's result will be PreconditionStatus.unsatisfied().
evaluatePreconditionById(PreconditionId id, {bool ignoreCache = false}) Future<Precondition>
Runs single precondition test. If the test is already running it won't be started again and you will receive the result of already running evaluation. If the test has dependencies, they will be evaluated first. If they fail, your test won't be run at all and it's result will be PreconditionStatus.unsatisfied().
evaluatePreconditions({bool ignoreCache = false}) Future<Iterable<Precondition>>
Run evaluation of all preconditions registered in this repository. Run order respects dependencies but when possible, tests are evaluated in parallel.
getAllPreconditions() Iterable<Precondition>
Returns all known preconditions in this repository.
getPrecondition(PreconditionId id) Precondition?
Returns desired precondition or null, if it's not registered by registerPrecondition() or registerAggregatePrecondition()
getUnsatisfiedPreconditions() Iterable<Precondition>
Returns all known preconditions in this repository which has other Precondition.status then PreconditionStatus.satisfied().
hasAnyUnsatisfiedPreconditions() bool
Is there any precondition in this repository in other Precondition.status then PreconditionStatus.satisfied()?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
registerAggregatePrecondition(PreconditionId id, Iterable<PreconditionId> dependsOn, {dynamic resolveTimeout = const Duration(seconds: 10), dynamic satisfiedCache = Duration.zero, dynamic notSatisfiedCache = Duration.zero, StatusBuilder? statusBuilder}) Precondition
Very similar to registerPrecondition, but the test it itself is always successful and the result of this precondition depends solely on "parent" preconditions defined in dependsOn.
registerPrecondition(PreconditionId id, PreconditionFunction preconditionFunction, {String? description, Iterable<PreconditionId> dependsOn = const [], dynamic resolveTimeout = const Duration(seconds: 10), dynamic satisfiedCache = Duration.zero, dynamic notSatisfiedCache = Duration.zero, StatusBuilder? statusBuilder, DependenciesStrategy? dependenciesStrategy}) Precondition
Use this method to register your PreconditionFunction with given unique id.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited

Operators

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