onBackground static method

String onBackground(
  1. AnsiColor background,
  2. String text, [
  3. AnsiColor? foreground
])

Applies a background color and optional foreground to the given text.

If foreground is provided, it wraps the background-colored text with the foreground style.

Example:

print(AnsiOutput.onBackground(AnsiColor.BG_BLUE, "Note", AnsiColor.WHITE));

Implementation

static String onBackground(AnsiColor background, String text, [AnsiColor? foreground]) {
  final base = background(text);
  return foreground != null ? foreground(base) : base;
}