PrettyPrinter constructor

PrettyPrinter({
  1. int stackTraceBeginIndex = 0,
  2. int? methodCount = 2,
  3. int? errorMethodCount = 8,
  4. int lineLength = 120,
  5. bool colors = true,
  6. bool printEmojis = true,
  7. @Deprecated("Use `dateTimeFormat` with `DateTimeFormat.onlyTimeAndSinceStart` or `DateTimeFormat.none` instead.") bool? printTime,
  8. DateTimeFormatter dateTimeFormat = DateTimeFormat.none,
  9. Map<Level, bool> excludeBox = const {},
  10. bool noBoxingByDefault = false,
  11. List<String> excludePaths = const [],
  12. Map<Level, AnsiColor>? levelColors,
  13. Map<Level, String>? levelEmojis,
})

Implementation

PrettyPrinter({
  this.stackTraceBeginIndex = 0,
  this.methodCount = 2,
  this.errorMethodCount = 8,
  this.lineLength = 120,
  this.colors = true,
  this.printEmojis = true,
  @Deprecated(
      "Use `dateTimeFormat` with `DateTimeFormat.onlyTimeAndSinceStart` or `DateTimeFormat.none` instead.")
  bool? printTime,
  DateTimeFormatter dateTimeFormat = DateTimeFormat.none,
  this.excludeBox = const {},
  this.noBoxingByDefault = false,
  this.excludePaths = const [],
  this.levelColors,
  this.levelEmojis,
})  : assert(
          (printTime != null && dateTimeFormat == DateTimeFormat.none) ||
              printTime == null,
          "Don't set printTime when using dateTimeFormat"),
      dateTimeFormat = printTime == null
          ? dateTimeFormat
          : (printTime
              ? DateTimeFormat.onlyTimeAndSinceStart
              : DateTimeFormat.none) {
  startTime ??= DateTime.now();

  var doubleDividerLine = StringBuffer();
  var singleDividerLine = StringBuffer();
  for (var i = 0; i < lineLength - 1; i++) {
    doubleDividerLine.write(doubleDivider);
    singleDividerLine.write(singleDivider);
  }

  _topBorder = '$topLeftCorner$doubleDividerLine';
  _middleBorder = '$middleCorner$singleDividerLine';
  _bottomBorder = '$bottomLeftCorner$doubleDividerLine';

  // Translate excludeBox map (constant if default) to includeBox map with all Level enum possibilities
  _includeBox = {};
  for (var l in Level.values) {
    _includeBox[l] = !noBoxingByDefault;
  }
  excludeBox.forEach((k, v) => _includeBox[k] = !v);
}