build method
- ParagraphBuilder builder, {
- TextScaler textScaler = TextScaler.noScaling,
- List<
PlaceholderDimensions> ? dimensions,
override
Apply the style, text, and children of this object to the given ParagraphBuilder, from which a Paragraph can be obtained. Paragraph objects can be drawn on Canvas objects.
Rather than using this directly, it's simpler to use the TextPainter class to paint TextSpan objects onto Canvas objects.
Implementation
@override
void build(
ui.ParagraphBuilder builder, {
TextScaler textScaler = TextScaler.noScaling,
List<PlaceholderDimensions>? dimensions,
}) {
assert(debugAssertIsValid());
final bool hasStyle = style != null;
if (hasStyle) {
builder.pushStyle(style!.getTextStyle(textScaler: textScaler));
}
if (text != null) {
try {
builder.addText(text!);
} on ArgumentError catch (exception, stack) {
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'painting library',
context: ErrorDescription('while building a TextSpan'),
silent: true,
));
// Use a Unicode replacement character as a substitute for invalid text.
builder.addText('\uFFFD');
}
}
final List<InlineSpan>? children = this.children;
if (children != null) {
for (final InlineSpan child in children) {
child.build(
builder,
textScaler: textScaler,
dimensions: dimensions,
);
}
}
if (hasStyle) {
builder.pop();
}
}