destroy method

void destroy()

Destroys the bytes.

The method overwrites the bytes with zeroes unless overwriting causes UnsupportedError. Finally the reference to the list is discarded, freeing it for garbage collection.

After destroying bytes, any attempt to read them will cause StateError.

Implementation

void destroy() {
  final bytes = _bytes;
  if (bytes != null) {
    _bytes = null;
    if (overwriteWhenDestroyed) {
      try {
        for (var i = 0; i < bytes.length; i++) {
          bytes[i] = 0;
        }
      } on UnsupportedError {
        // Ignore error
      } on StateError {
        // Ignore error
      }
    }
  }
}