preconditions library Null safety

Classes

Precondition
PreconditionsRepository creates this object from PreconditionFunction which you register in PreconditionsRepository.registerPrecondition(). Think of it as a handle to your precondition. It is a mutable ChangeNotifier, but is modified only through methods of PreconditionsRepository and from your point of view is read-only. It's possible to integrate it with your state management tool, for example:
PreconditionId
Unique identificator of precondition.
PreconditionsRepository
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.
PreconditionStatus
Result of precondition check. Your precondition function should return one of two possible results:

Constants

forEver → const Duration
Use this constant to specify unlimited cache in PreconditionsRepository.registerPrecondition
Duration(days: 365 * 100, milliseconds: 42)

Enums

DependenciesStrategy
How should precondition handle it's dependencies.

Typedefs

PreconditionFunction = FutureOr<PreconditionStatus> Function()
Implement your precondition verification in form of this function type. Return either: PreconditionStatus.satisfied() or PreconditionStatus.unsatisfied() as a result of your test.
StatusBuilder = Widget Function(BuildContext context, PreconditionStatus status)
Optionally provide this Widget builder to render a feedback to your user, i.e. "Please grant all permissions", etc. Example: