encodeFixedLengthList function
Implementation
Uint8List encodeFixedLengthList(List<dynamic> l, String type, int length) {
if(l.length != length) {
throw Exception("incompatibal input list length for type $type");
}
if(isDynamicType(type)) {
List<int> relocates = [];
var baseOffset = 32 * length;
List<int> contents = [];
for(var i = 0; i < length; i++) {
relocates.addAll(encodeInt(baseOffset + contents.length));
contents.addAll(encodeType(type, l[i]));
}
return Uint8List.fromList(relocates + contents);
} else {
List<int> contents = [];
for(var i = 0; i < length; i++) {
contents.addAll(encodeType(type, l[i]));
}
return Uint8List.fromList(contents);
}
}