createDiagramParagraph function
TextPainter
createDiagramParagraph(
- List<
TextRun> runs, - TextRole role,
- DiagramColor foreground,
- ParagraphAlignment alignment, {
- required double fontSize,
- ParagraphDirection direction = ParagraphDirection.ltr,
- double defaultFontSize = diagramDefaultFontSize,
- int? maxLines,
- double? lineHeight,
Implementation
TextPainter createDiagramParagraph(
List<TextRun> runs,
TextRole role,
DiagramColor foreground,
ParagraphAlignment alignment, {
required double fontSize,
ParagraphDirection direction = ParagraphDirection.ltr,
double defaultFontSize = diagramDefaultFontSize,
int? maxLines,
double? lineHeight,
}) => TextPainter(
text: TextSpan(
style: diagramTextRunStyle(
TextRun('', fontSize: fontSize),
role,
foreground,
),
children: [
for (final run in runs)
TextSpan(
text: run.text,
style: diagramTextRunStyle(
run,
role,
foreground,
defaultFontSize: defaultFontSize,
),
),
],
),
textDirection: direction == ParagraphDirection.rtl
? TextDirection.rtl
: TextDirection.ltr,
textAlign: switch (alignment) {
ParagraphAlignment.start => TextAlign.start,
ParagraphAlignment.center => TextAlign.center,
ParagraphAlignment.end => TextAlign.end,
ParagraphAlignment.justify => TextAlign.justify,
},
maxLines: maxLines,
strutStyle: StrutStyle(
fontSize: fontSize,
height: lineHeight == null
? diagramDefaultTextHeight
: lineHeight / fontSize,
forceStrutHeight: lineHeight != null,
),
);