Style class

Incremental text style with foreground/background colors and modifiers.

Styles are combined with patch: the new style adds its values without replacing existing ones (unless the new one explicitly sets them).

final base = Style(fg: Color.red, addModifier: Modifier.bold);
final overlay = Style(bg: Color.blue);
final result = base.patch(overlay);

Constructors

Style({Color? fg, Color? bg, RgbColor? fgRgb, RgbColor? bgRgb, IndexedColor? fgIndexed, IndexedColor? bgIndexed, Modifier addModifier = Modifier.none, Modifier subModifier = Modifier.none})
const

Properties

addModifier Modifier
Modifiers to add.
final
bg Color?
Background color.
final
bgIndexed IndexedColor?
Indexed background color (256-color palette).
final
bgRgb RgbColor?
RGB background color (24-bit).
final
fg Color?
Foreground color.
final
fgIndexed IndexedColor?
Indexed foreground color (256-color palette).
final
fgRgb RgbColor?
RGB foreground color (24-bit).
final
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subModifier Modifier
Modifiers to remove.
final

Methods

copyWith({Color? fg, Color? bg, RgbColor? fgRgb, RgbColor? bgRgb, IndexedColor? fgIndexed, IndexedColor? bgIndexed, Modifier? addModifier, Modifier? subModifier}) Style
hasModifier(Modifier modifier) bool
Whether this style has modifier set (added and not removed).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch(Style other) Style
Merge other into this style.
toString() String
A string representation of this object.
override

Operators

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

Constants

empty → const Style
Empty style with no fields set.
reset → const Style
Reset style that clears colors and removes all modifiers.