r<T> method
dynamic
r<
T>({ - int bytes = 0,
})
Implementation
dynamic r<T>({int bytes = 0}) {
var bytes0 = bytes;
final model = GenericsModel(T);
final typeName = model.type.toString();
if (bytes0 == 0) {
switch (typeName) {
case 'Uint8':
case 'Int8':
bytes0 = 1;
case 'Uint16':
case 'Int16':
bytes0 = 2;
case 'Uint32':
case 'Int32':
case 'Float':
bytes0 = 4;
case 'Uint64':
case 'Int64':
bytes0 = 8;
default:
break;
}
}
final list = _read(bytes0);
final byteData = Uint8List.fromList(list).buffer.asByteData();
switch (typeName) {
case 'Uint8List':
return list;
case 'ByteData':
return byteData;
case 'String':
return String.fromCharCodes(Uint8List.fromList(list));
case 'Int8':
return byteData.getInt8(0);
case 'Uint8':
return byteData.getUint8(0);
case 'Int16':
return byteData.getInt16(0, Endian.little);
case 'Uint16':
return byteData.getUint16(0, Endian.little);
case 'Int32':
return byteData.getInt32(0, Endian.little);
case 'Uint32':
return byteData.getUint32(0, Endian.little);
case 'Float':
return byteData.getFloat32(0, Endian.little);
case 'Int64':
return byteData.getInt64(0, Endian.little);
case 'Uint64':
return byteData.getUint64(0, Endian.little);
}
return null;
}