pprint function

String pprint(
  1. RollResult? rr, {
  2. String indent = '',
})

Implementation

String pprint(RollResult? rr, {String indent = ''}) {
  if (rr == null) {
    return '';
  }
  final buffer = StringBuffer(indent);
  buffer.write(rr.toString());
  if (rr.left != null && rr.left?.opType != OpType.value) {
    buffer
      ..write('\n')
      ..write(pprint(rr.left, indent: '$indent    '));
  }
  if (rr.right != null && rr.right?.opType != OpType.value) {
    buffer
      ..write('\n')
      ..write(
        pprint(
          rr.right,
          indent: '$indent    ',
        ),
      );
  }

  return buffer.toString();
}