Google is committed to advancing racial equity for Black communities. See how.

hexDump method

*<Null safety>*

void hexDump ()

Implementation

void hexDump() {
  const int width = 16;
  Uint8List list = Uint8List.view(data.buffer, 0);
  StringBuffer buffer = StringBuffer();
  final RegExp isPrintable = RegExp(r'\w');
  for (int i = 0; i < data.lengthInBytes; i += width) {
    StringBuffer hex = StringBuffer();
    StringBuffer printable = StringBuffer();
    for (int j = 0; j < width && i + j < data.lengthInBytes; j++) {
      int v = list[i + j];
      String s = v.toRadixString(16);
      if (s.length == 1)
        hex.write('0$s ');
      else
        hex.write('$s ');

      s = String.fromCharCode(v);
      if (isPrintable.hasMatch(s)) {
        printable.write(s);
      } else {
        printable.write('.');
      }
    }
    buffer.write('${hex.toString().padRight(3 * width)} $printable\n');
  }

  print('==================================================\n'
      '$buffer'
      '==================================================');
}