formatParagraphsInRange static method

TextStory formatParagraphsInRange({
  1. required TextStory story,
  2. required int start,
  3. required int? end,
  4. required TextParagraph format(
    1. TextParagraph,
    2. TextParagraph?
    ),
})

Transforms selected paragraphs in order. Each paragraph observes the already transformed predecessor. Text, identity and region remain stable.

Implementation

static TextStory formatParagraphsInRange({
  required TextStory story,
  required int start,
  required int? end,
  required TextParagraph Function(TextParagraph, TextParagraph?) format,
}) => _formatSelectedBlocks(story, start, end, (block, previous) {
  final next = format(block, previous);
  if (next.id != block.id ||
      next.plainText != block.plainText ||
      next.role != block.role ||
      next.effectiveSlotId != block.effectiveSlotId) {
    throw ArgumentError(
      'Paragraph formatting cannot replace text, identity or region.',
    );
  }
  return next;
});