Text
Display text with styling options
Renders a string. Set type with font; see Font for the named styles and Font.custom.
Methods
Text(content, options?)WidgetNodeRenders a string.
- content string | LiveText required
The string to render, or a live date from a DateTime's countdown(), elapsed(), timer() or offset(), which keeps counting on the Home Screen.
- options Any
- font RootlessFont
Size, weight, family and design as one value.
- color Color
Text colour.
- textAlign TextAlign
A TextAlign, for alignment inside the available width.
- maxLines Number
Truncate beyond this many lines.
- overflow TextOverflow
A TextOverflow, for how truncation looks. Needs maxLines.
- lineSpacing Number
Extra points between lines.
- font RootlessFont
Text.measure(text, options?)AnyHow big this string will be. Pair with Widget.size rather than guessing whether text fits.
- text String required
The string to measure.
- options Any
- font RootlessFont
The font it will be drawn in. Left out, the system font at 14 points.
- maxWidth Number
The width it has to fit in.
- maxLines Number
The line budget, for
fits.
- font RootlessFont
returns { width, height, lines, lineHeight, fits }. fits is false when the string needs more lines than maxLines allows.
Examples
Styled text
Text("Hello World", {
color: Color.white(),
font: Font.system(24, FontWeight.bold),
textAlign: "center"
})