OudsBodyText class
Reference design version : 1.0.0
Body styles are designed for everyday text content such as paragraphs, descriptions, and informational messages. They prioritize readability and provide a comfortable reading experience across all screen sizes. Multiple size options allow content importance to be expressed while maintaining consistency. Their typography automatically scales across breakpoints to support responsive layouts.
OudsBodyText(
text: 'Body copy',
size: OudsBodyTextSize.medium
)
A color override can be provided when the default theme color is not suitable, for example when the text is displayed on a colored surface:
OudsBodyText(
text: 'Body',
size: OudsBodyTextSize.medium,
color: OudsTheme.of(context).colorScheme(context).contentDefault,
)
Multiple colors can be used simultaneously within the same text.
This widget also accepts lightweight rich text: **bold**, ~~line through~~ and
[link](https://example.com) are supported directly in text, and a .rich constructor
(OudsBodyText.rich) is exposed to color only part of the text. Build the .rich
constructor's text argument with buildOudsAnnotatedText.
The user must ensure that the contrast between the colors used meets current accessibility standards and that the colors align with the brand’s and its entity’s visual identity.
OudsBodyText.rich(
text: buildOudsAnnotatedText((builder) {
builder.append('Body with ');
builder.withColor((context) => color, () => builder.append('colored text'));
}),
)
Use onLinkTap to handle taps on markdown-style links ([label](url)) embedded in text:
OudsBodyText(
text: 'Read our [privacy policy](https://example.com/privacy) for more details.',
onLinkTap: (url) {
// Open the URL, e.g. via url_launcher.
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- OudsBodyText
Constructors
- OudsBodyText({Key? key, required String text, Color? color, OudsBodyTextSize size = OudsBodyTextSize.medium, OudsTextWeight weight = OudsTextWeight.defaultWeight, int? maxLines, TextAlign? textAlign, TextOverflow? overflow, bool? softWrap})
-
Creates an OudsBodyText.
const
- OudsBodyText.rich({Key? key, required OudsAnnotatedText text, Color? color, OudsBodyTextSize size = OudsBodyTextSize.medium, OudsTextWeight weight = OudsTextWeight.defaultWeight, void onLinkTap(String url)?, int? maxLines, TextAlign? textAlign, TextOverflow? overflow, bool? softWrap})
-
Creates an OudsBodyText whose content is composed of multiple spans, some of which can be
colored independently of the others. Build
textwith buildOudsAnnotatedText to color part of the text, e.g. to highlight a word or phrase.const
Properties
- color → Color?
-
An optional color override. When null, the theme's
contentDefaultcolor is used.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxLines → int?
-
An optional maximum number of lines for the text to span, wrapping if necessary.
If the text exceeds the given number of lines, it will be truncated according to overflow and
softWrap.
final
- onLinkTap → void Function(String url)?
-
Callback invoked when a
[link](url)inside text or the annotated text is tapped.final - overflow → TextOverflow?
-
How visual overflow should be handled.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → OudsBodyTextSize
-
The size of the body text, see OudsBodyTextSize. Defaults to OudsBodyTextSize.medium.
final
- softWrap → bool?
-
Whether the text should break at soft line breaks. If false, the glyphs in the
text will be positioned as if there was unlimited horizontal space. If softWrap is false,
overflow and TextAlign may have unexpected effects.
final
- text → String
-
The text to display. Empty when built via OudsBodyText.rich.
final
- textAlign → TextAlign?
-
Alignment of the text within the lines of the paragraph. See TextAlign.
final
- weight → OudsTextWeight
-
The emphasis level of the body text, see OudsTextWeight.
Defaults to OudsTextWeight.defaultWeight.
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
-
textStyle(
BuildContext context) → TextStyle - Returns the TextStyle associated with size and weight in the active theme.
-
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