Recurrence class
Use this class to define a recurrence pattern.
range is very important as its TimeRange.from
property is used to
calculate the next occurrence. TimeRange.from
could be the first
occurence as range is inclusive.
Use toJson and fromJson to serialize and deserialize a recurrence.
For two rules to be equal, they must have the same range and the same rules (with the same order)
Constructors
-
Recurrence.new({required TimeRange range, required List<
RecurrenceRule> rules}) -
const
-
Recurrence.forever({required List<
RecurrenceRule> rules}) -
Creates a recurrence that starts at
Moment.minValue
and ends atMoment.maxValue
.factory -
Recurrence.fromIndefinitely({required List<
RecurrenceRule> rules, DateTime? start}) -
Creates a recurrence that starts at the given
start
date and ends at theMoment.maxValue
factory -
Recurrence.fromJson(Map<
String, dynamic> json) -
Deserializes a JSON object into a Recurrence object.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- range → TimeRange
-
Its
.from
will be used as anchor for the next occurrence.final -
rules
→ List<
RecurrenceRule> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{TimeRange? range, List< RecurrenceRule> ? rules}) → Recurrence -
nextAbsoluteOccurrence(
DateTime from, {TimeRange? subrange}) → DateTime? -
Returns the next occurence anchored to
from
. If the nearest occurence does not fit in range, returns null. -
nextOccurrence(
DateTime from, {TimeRange? subrange}) → DateTime? -
Returns the closest next occurence anchored to
from
, that also fits the range. If there are no occurrences, it returns null. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
occurrences(
{TimeRange? subrange}) → List< DateTime> -
Returns all occurences within the
subrange
. -
previousAbsoluteOccurrence(
DateTime from, {TimeRange? subrange}) → DateTime? -
Returns the previous occurence anchored to
from
. If the nearest occurence does not fit in range, returns null. -
previousOccurrence(
DateTime from, {TimeRange? range}) → DateTime? -
Returns the closest previous occurence anchored to
from
, that also fits therange
. If there are no occurrences, it returns null. -
realign(
) → Recurrence -
serialize(
) → String - Serializes the rule into a string.
-
toJson(
) → Map< String, dynamic> - Serializes the rule into a JSON object.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
deserialize(
String serialized) → Recurrence - Deserializes a string into a Recurrence object.
-
parse(
String serialized) → Recurrence - Synonym for deserialize
-
tryParse(
String serialized) → Recurrence? - Synonym for deserialize, but returns null if the string is not valid