wrap method

String wrap(
  1. String text, {
  2. AnsiColor? foreground,
  3. AnsiColor? background,
  4. AnsiColor? bright,
  5. bool? reverse,
  6. bool? underline,
})

Wraps text into the defined styles with option to override a style.

Implementation

String wrap(
  String text, {
  AnsiColor? foreground,
  AnsiColor? background,
  AnsiColor? bright,
  bool? reverse,
  bool? underline,
}) {
  final underlineStyle = (underline ?? false) ? underline : this.underline;

  final rvStyle = (reverse ?? false) ? reverse : this.reverse;

  final fgColor = (foreground != null)
      ? foreground
      : (this.foreground != null)
          ? this.foreground
          : null;

  final bgColor = (background != null)
      ? background
      : (this.background != null)
          ? this.background
          : null;
  final brColor = (bright != null)
      ? bright
      : (this.bright != null)
          ? this.bright
          : null;
  return wrapWith(
    text,
    background: bgColor,
    foreground: fgColor,
    bright: brColor,
    reverse: rvStyle,
    underline: underlineStyle,
  );
}