add method

void add(
  1. Object? data, {
  2. String? description,
})

Adds data to this bytes instance.

Implementation

void add(Object? data, {String? description}) {
  if (data == null) return;

  if (data is List<int>) {
    write(data, description: description);
  } else if (data is BytesEmitter) {
    writeBytes(data, description: description);
  } else if (data is int) {
    writeByte(data, description: description);
  } else {
    throw StateError("Can't handle data type: ${data.runtimeType}");
  }
}