getPrintable method

  1. @override
Object getPrintable(
  1. bool useColor
)
override

The message to be printed out.

The useColor argument should be used to determine whether to use color or any other styling in the returned Object.

Implementation

@override
Object getPrintable(bool useColor) {
  if (useColor) {
    List<String> end = _endsWithReset() ? const [] : _reset;
    return parts
        .map((e) => e.when(code: (c) => c.escape, text: (t) => t.toString()))
        .followedBy(end)
        .join('');
  }
  return parts
      .map((e) => e.when(code: (c) => null, text: (t) => t.toString()))
      .where((e) => e != null)
      .join('');
}