ByteArray.fromList constructor

ByteArray.fromList(
  1. List<int> bytes
)

Creates a ByteArray from an existing list of bytes.

bytes the byte data to copy

A wrapper for byte arrays similar to Java's byte[] with utility methods.

This class provides a convenient interface for working with byte arrays, wrapping Dart's List<int> with Java-like methods and additional utilities.

Example usage:

ByteArray bytes = ByteArray.fromString("Hello");
ByteArray copy = bytes.copy();
bytes.set(0, 72); // Change 'H' to 'H' (same value)

print(bytes.toString()); // "Hello"
print(bytes.length); // 5

Implementation

factory ByteArray.fromList(List<int> bytes) {
  return ByteArray._(List<int>.from(bytes));
}