Chunk.fromJson constructor

Chunk.fromJson(
  1. Object? j
)

Implementation

factory Chunk.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return Chunk(
    name: switch (json['name']) {
      null => '',
      Object $1 => decodeString($1),
    },
    data: switch (json['data']) {
      null => null,
      Object $1 => ChunkData.fromJson($1),
    },
    customMetadata: switch (json['customMetadata']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) CustomMetadata.fromJson(i)],
      _ => throw const FormatException('"customMetadata" is not a list'),
    },
    createTime: switch (json['createTime']) {
      null => null,
      Object $1 => Timestamp.fromJson($1),
    },
    updateTime: switch (json['updateTime']) {
      null => null,
      Object $1 => Timestamp.fromJson($1),
    },
    state: switch (json['state']) {
      null => Chunk_State.$default,
      Object $1 => Chunk_State.fromJson($1),
    },
  );
}