apply function

String apply(
  1. String text, {
  2. ANSIStyles? color,
  3. ANSIStyles? bg,
  4. ANSIStyles? fontStyle,
})

return text with ANSI format example: print('\u{1B}[31m\u{1B}[103mHello World!\u{1B}[0m');

Implementation

String apply(
  String text, {
  ANSIStyles? color,
  ANSIStyles? bg,
  ANSIStyles? fontStyle,
}) {
  String rs = text;

  if (color != null) {
    rs = '\u{1B}[${_getStyle(color)}m' + rs;
  }
  if (bg != null) {
    rs = '\u{1B}[${_getStyle(bg)}m' + rs;
  }
  if (fontStyle != null) {
    rs = '\u{1B}[${_getStyle(fontStyle)}m' + rs;
  }
  rs = rs + '\u{1B}[0m';
  return rs;
}