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}) {
  var underlineStyle = (underline ?? false) ? underline : this.underline;

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

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

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