concatMixed static method

Uint8List concatMixed(
  1. List items
)

Concatenate mixed types (strings and byte arrays) All strings are converted to bytes using UTF-8 encoding

Implementation

static Uint8List concatMixed(List<dynamic> items) {
  final byteArrays = <Uint8List>[];

  for (final item in items) {
    if (item is String) {
      byteArrays.add(stringToBytes(item));
    } else if (item is Uint8List) {
      byteArrays.add(item);
    } else if (item is List<int>) {
      byteArrays.add(Uint8List.fromList(item));
    } else {
      throw ArgumentError('Unsupported type: ${item.runtimeType}. '
          'Only String, Uint8List, and List<int> are supported.');
    }
  }

  return concatBytes(byteArrays);
}