dumpInfo function

String dumpInfo(
  1. BtInfo info,
  2. {bool printToTerminal = true,
  3. bool brief = false}
)

Implementation

String dumpInfo(
  BtInfo info, {
  bool printToTerminal = true,
  bool brief = false,
}) {
  final encoder = JsonEncoder.withIndent('  ');
  final json = BtEncoder(info).toJSON();
  if (json['info']['pieces'] != null) {
    json['info']['pieces'] = json['info']['pieces'].map(hex.encode).toList();
  }
  if (brief) {
    final len = json['info']['pieces'].length;
    if(len > 5) {
      json['info']['pieces'] = json['info']['pieces'].getRange(0, 5).toList();
      json['info']['pieces'].add('<${len-5} more...>');
    }
  }
  final output = encoder.convert(json);
  if (printToTerminal) {
    print(output);
  }
  return output;
}