buildText method
Builds RichText.
Implementation
Widget? buildText(
BuildTree tree,
InheritedProperties resolved,
InlineSpan text,
) {
// pre-compute as many parameters as possible
final maxLines = tree.maxLines > 0 ? tree.maxLines : null;
final softWrap = resolved.get<CssWhitespace>() != CssWhitespace.nowrap;
final textAlign = resolved.get<TextAlign>() ?? TextAlign.start;
final textDirection = resolved.get<TextDirection>();
return Builder(
builder: (context) {
// TODO: remove Builder when ListView stops providing its own registrar
final selectionRegistrar = SelectionContainer.maybeOf(context);
final selectionColor = selectionRegistrar != null
? DefaultSelectionStyle.of(context).selectionColor ??
DefaultSelectionStyle.defaultColor
: null;
Widget built = RichText(
maxLines: maxLines,
overflow: tree.overflow,
selectionColor: selectionColor,
selectionRegistrar: selectionRegistrar,
softWrap: softWrap,
text: text,
textAlign: textAlign,
textDirection: textDirection,
);
if (selectionRegistrar != null) {
built = MouseRegion(cursor: SystemMouseCursors.text, child: built);
}
return built;
},
);
}