formatParagraphsInRange static method
TextStory
formatParagraphsInRange({
- required TextStory story,
- required int start,
- required int? end,
- required TextParagraph format(),
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;
});