canCreateRepeat method
Whether another instance of repeat can be added after
currentMultiplicity instances at repeatRef: always, unless the
repeat is fixed (noAddRemove), and for a jr:count repeat while
the count is larger.
The core of JavaRosa's canCreateRepeat(TreeReference, FormIndex).
Implementation
bool canCreateRepeat(
TreeReference repeatRef,
GroupDef repeat,
int currentMultiplicity,
) {
if (!repeat.noAddRemove) return true;
final countRef = repeat.count;
if (countRef == null) return false;
final countNode = mainInstance.resolveReference(
countRef.contextualize(repeatRef)!,
);
if (countNode == null) return false;
return answerDataToInt(countNode.value) > currentMultiplicity;
}