FossText class Typography

FossText, light theme FossText, dark theme

See the text documentation ↗ or try it live in the playground ↗.

On-brand text in one line. FossText renders a string in a FossTypography step at one of four weights, resolving the type scale and the bundled font from context.fossTheme so the text stays on theme without reaching into the tokens.

Pick the step and weight with size and weight, or use a named constructor (FossText.body, FossText.title, FossText.heading, and the like) for a common role. color takes a semantic FossTextColor role; when null the text uses the foreground role. style merges over the resolved style, winning on any field it sets. Set header on a true document heading so assistive technology can navigate to it. The remaining parameters pass straight through to the underlying Text.

Customize globally by passing your own FossThemeData, or per instance through the widget's style object. There are no per-instance token props: to change color, radius, or spacing, change the theme.

FossText.title('Account settings');
FossText(
  'The quick brown fox.',
  size: FossTextSize.sm,
  color: FossTextColor.mutedForeground,
);
Inheritance
Annotations

Constructors

FossText(String data, {FossTextSize size = FossTextSize.base, FossTextWeight weight = FossTextWeight.regular, FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
FossText, light theme FossText, dark theme
const
FossText.body(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Body text: FossTextSize.sm, FossTextWeight.regular.
const
FossText.caption(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Caption text: FossTextSize.xs, FossTextWeight.regular.
const
FossText.display(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Display text: FossTextSize.xl2, FossTextWeight.bold.
const
FossText.heading(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Heading text: FossTextSize.xl, FossTextWeight.semibold.
const
FossText.label(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Label text: FossTextSize.sm, FossTextWeight.medium.
const
FossText.title(String data, {FossTextColor? color, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool? softWrap, String? semanticsLabel, TextStyle? style, bool header = false, Key? key})
Title text: FossTextSize.lg, FossTextWeight.semibold.
const

Properties

color → FossTextColor?
The color role. Defaults to the foreground role when null.
final
data → String
The string to render.
final
hashCode → int
The hash code for this object.
no setterinherited
Whether to mark the text as a heading for assistive technology, so screen readers can navigate to it by heading. Defaults to false; set it on true document headings, not on every visually large label.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxLines → int?
The maximum number of lines before the text clips or ellipsizes.
final
overflow → TextOverflow?
How visual overflow is handled.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel → String?
Accessibility name that replaces the visible string when set.
final
size → FossTextSize
The type step. Defaults to FossTextSize.base.
final
softWrap → bool?
Whether the text should wrap at soft line breaks.
final
style → TextStyle?
A per-instance style merged over the resolved style, winning on any field it sets.
final
textAlign → TextAlign?
How the text aligns horizontally.
final
weight → FossTextWeight
The weight. Defaults to FossTextWeight.regular.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited