TipRule class abstract

A condition for a tip to become available.

Rules are evaluated synchronously against the current state, so anything outside the tip system that a rule depends on is passed in through a TipParameter or counted with a TipEvent.

Implement this class for conditions the built-in rules cannot express.

Annotations

Constructors

TipRule()
Lets subclasses be const.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

evaluate(TipRuleContext context) → bool
Whether the rule holds in context.
nextChange(TipRuleContext context) → DateTime?
The earliest time after context.now at which the result of evaluate can change by itself, without any parameter, event or tip changing.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

allOf(List<TipRule> rules) → TipRule
Holds when every rule in rules holds.
anyOf(List<TipRule> rules) → TipRule
Holds when at least one rule in rules holds.
event(TipEvent event, bool predicate(TipEventDonations donations)) → TipRule
Holds while predicate returns true for the donations of event.
not(TipRule rule) → TipRule
Holds when rule does not.
parameter<T>(TipParameter<T> parameter, bool predicate(T value)) → TipRule
Holds while predicate returns true for the value of parameter.
tipInvalidated(Tip tip, {Duration minAge = Duration.zero, Set<TipInvalidationReason>? reasons}) → TipRule
Holds once tip has been invalidated, at least minAge ago, and, if reasons is given, for one of those reasons.