FontStyle class Styling

Represents a text font style in ANSI terminal sequences.

Provides predefined font styles such as bold, italic, underline, and strikethrough, identified by their ANSI style codes.

Properties

  • code: The ANSI code representing the font style.
  • name: A human-readable name of the font style.

Responsibilities

  • Map ANSI style codes to named font styles.
  • Provide a way to get a font style from its ANSI code.

Example

final boldStyle = FontStyle.bold;
print(boldStyle.code); // Outputs: 1
print(boldStyle.name); // Outputs: "bold"

final underlineStyle = FontStyle.fromCode(4);
print(underlineStyle.name); // Outputs: "underline"

See Also

  • ANSI escape codes for font styling.
  • AnsiColorType - For styling text with color

Constructors

FontStyle.fromCode(int code)
Returns the FontStyle matching the given ANSI code.
factory

Properties

code int
The ANSI style code for this font style.
final
hashCode int
The hash code for this object.
no setterinherited
name String
The human-readable name of this font style.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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

Constants

bold → const FontStyle
Bold font style (ANSI code 1).
italic → const FontStyle
Italic font style (ANSI code 3).
strikethrough → const FontStyle
Strikethrough font style (ANSI code 9).
underline → const FontStyle
Underline font style (ANSI code 4).
values → const List<FontStyle>
List of all predefined font styles.