ResourceContents.fromJson constructor

ResourceContents.fromJson(
  1. Map<String, Object?> json
)

Reads the branch json names; an unrecognised one is kept as UnknownResourceContents.

Implementation

factory ResourceContents.fromJson(Map<String, Object?> json) {
  if (json.containsKey('text') && json.containsKey('uri')) return TextResourceContents.fromJson(json);
  if (json.containsKey('blob') && json.containsKey('uri')) return BlobResourceContents.fromJson(json);
  return UnknownResourceContents.fromJson(json);
}