preconditions library Null safety


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:
Unique identificator of precondition.
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.
Result of precondition check. Your precondition function should return one of two possible results:


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


How should precondition handle it's dependencies.


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: