read method

  1. @override
Cryptocurrency read(
  1. BinaryReader reader
)
override

Is called when a value has to be decoded.

Implementation

@override
Cryptocurrency read(BinaryReader reader) {
  final numOfFields = reader.readByte();
  final fields = <int, dynamic>{
    for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
  };
  return Cryptocurrency(
    id: fields[0] as String,
    name: fields[1] as String,
    symbol: fields[2] as String,
    image: fields[3] as String,
    currentPriceUSD: fields[4] as num,
    marketCap: fields[5] as num,
    marketCapRank: fields[6] as int,
    totalVolume: fields[7] as num,
    priceChange24h: fields[8] as num,
    totalSupply: fields[9] as num,
  )..isFavorite = fields[10] as bool;
}