printRich function

void printRich(
  1. Object? object, {
  2. Shade? bg,
  3. Shade? fg,
  4. bool? bold,
  5. bool? dark,
  6. bool? italic,
  7. bool? underline,
  8. bool? blink,
  9. bool? reverse,
  10. bool? concealed,
})

Print object with settable styles and colors

Implementation

void printRich(
  Object? object, {
  Shade? bg,
  Shade? fg,
  bool? bold,
  bool? dark,
  bool? italic,
  bool? underline,
  bool? blink,
  bool? reverse,
  bool? concealed,
}) {
  final List<Styles> styles = [];
  styles.nonNullAdd(bg?.toStyle(true));
  styles.nonNullAdd(fg?.toStyle());
  styles.nonNullAdd(bold == true ? Styles.BOLD : null);
  styles.nonNullAdd(dark == true ? Styles.DARK : null);
  styles.nonNullAdd(italic == true ? Styles.ITALIC : null);
  styles.nonNullAdd(underline == true ? Styles.UNDERLINE : null);
  styles.nonNullAdd(blink == true ? Styles.BLINK : null);
  styles.nonNullAdd(reverse == true ? Styles.REVERSE : null);
  styles.nonNullAdd(concealed == true ? Styles.CONCEALED : null);

  Colorize string = Colorize("$object");
  for (Styles style in styles) {
    string.apply(style);
  }
  print(string);
}