apply method

Delta apply(
  1. RuleType ruleType,
  2. Document document,
  3. int index, {
  4. int? len,
  5. Object? data,
  6. Attribute? attribute,
})

Implementation

Delta apply(
  RuleType ruleType,
  Document document,
  int index, {
  int? len,
  Object? data,
  Attribute? attribute,
}) {
  for (final rule in _customRules + _rules) {
    if (rule.type != ruleType) {
      continue;
    }
    try {
      final result = rule.apply(document, index,
          len: len, data: data, attribute: attribute);
      if (result != null) {
        return result..trim();
      }
    } catch (e) {
      rethrow;
    }
  }
  throw FormatException(
    'Apply delta rules failed. No matching rule found for type: $ruleType',
  );
}