OudsCodeText class
Reference design version : 1.0.0
The Code style is dedicated to technical content such as code snippets, commands, system values, and identifiers. It uses a monospace typeface to preserve character alignment and improve readability of structured content. Available in a single size, it provides a consistent presentation of technical information throughout the product. Its use should be limited to content that requires an accurate code-like representation.
OudsCodeText(text: 'const x = 1;')
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:
OudsCodeText(
text: 'const x = 1;',
color: OudsTheme.of(context).colorScheme(context).contentDefault,
)
Multiple colors can be used simultaneously within the same text.
The .rich constructor (OudsCodeText.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.
OudsCodeText.rich(
text: buildOudsAnnotatedText((builder) {
builder.append('const x = ');
builder.withColor((context) => color, () => builder.append('1;'));
}),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- OudsCodeText
Constructors
- OudsCodeText({Key? key, required String text, Color? color})
-
Creates an OudsCodeText.
const
- OudsCodeText.rich({Key? key, Color? color, required OudsAnnotatedText text, int? maxLines, TextAlign? textAlign, TextOverflow? overflow, bool? softWrap})
-
Creates an OudsCodeText 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
- overflow → TextOverflow?
-
How visual overflow should be handled.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- 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 OudsCodeText.rich.
final
- textAlign → TextAlign?
-
Alignment of the text within the lines of the paragraph. See TextAlign.
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 used to render the code text 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