Data.fromList constructor

Data.fromList(
  1. List<int> l
)

A new Data object containing the given bytes.

Implementation

factory Data.fromList(List<int> l) {
  final buffer = calloc<Uint8>(l.length);
  try {
    buffer.asTypedList(l.length).setAll(0, l);

    final data =
        ncb.NSData.dataWithBytes_length_(linkedLibs, buffer.cast(), l.length);
    return Data._(data);
  } finally {
    calloc.free(buffer);
  }
}