applyTo method
Wraps text with ANSI escape sequences for the active style flags.
Implementation
String applyTo(String text) {
final codes = <String>[];
if (bold) codes.add('1');
if (italic) codes.add('3');
if (underline) codes.add('4');
if (invert) codes.add('7');
if (strike) codes.add('9');
if (doubleUnderline) codes.add('21');
if (framed) codes.add('51');
if (foreground != null) {
codes.add('38;2;${_rgb(foreground!)}');
}
if (background != null) {
codes.add('48;2;${_rgb(background!)}');
}
if (codes.isEmpty) return text;
return '\x1B[${codes.join(';')}m$text\x1B[0m';
}