encode method

  1. @override
String encode(
  1. List<T> values
)
override

Encodes a list of elements of type T into a Base64-encoded String.

Each element is written to binary data using the write method, and the resulting bytes are encoded as a Base64 String.

Implementation

@override

/// Encodes a list of elements of type [T] into a Base64-encoded [String].
///
/// Each element is written to binary data using the [write] method,
/// and the resulting bytes are encoded as a Base64 [String].
String encode(List<T> values) {
  final bytes = Uint8List(values.length * byteSize);
  final byteData = ByteData.sublistView(bytes);
  for (var i = 0; i < values.length; i++) {
    write(byteData, i * byteSize, values[i]);
  }
  return base64Encode(bytes);
}