readValueOfType method

  1. @override
dynamic readValueOfType(
  1. int type,
  2. ReadBuffer buffer
)
override

Reads a value of the indicated type from buffer.

The codec can be extended by overriding this method, calling super for types that the extension does not handle. See the discussion at writeValue.

Implementation

@override
dynamic readValueOfType(int type, ReadBuffer buffer) {
  switch (type) {
    case _kDateTime:
      return DateTime.fromMillisecondsSinceEpoch(buffer.getInt64());
    case _kUri:
      final int length = readSize(buffer);
      final String string = utf8.decoder.convert(buffer.getUint8List(length));
      return Uri.parse(string);
    default:
      return super.readValueOfType(type, buffer);
  }
}