deserializeByClassName method

dynamic deserializeByClassName(
  1. Map<String, dynamic> data
)

Deserialize the provided json data by using the className stored in the data.

Implementation

dynamic deserializeByClassName(Map<String, dynamic> data) {
  var className = data['className'];
  switch (className) {
    case 'int':
      return deserialize<int>(data['data']);
    case 'double':
      return deserialize<double>(data['data']);
    case 'String':
      return deserialize<String>(data['data']);
    case 'bool':
      return deserialize<bool>(data['data']);
    case 'DateTime':
      return deserialize<DateTime>(data['data']);
    case 'ByteData':
      return deserialize<ByteData>(data['data']);
    case 'Duration':
      return deserialize<Duration>(data['data']);
    case 'UuidValue':
      return deserialize<UuidValue>(data['data']);
  }
  throw FormatException('No deserialization found for type named $className');
}