TextAnnotation.fromJson constructor

TextAnnotation.fromJson(
  1. Map<String, dynamic> json
)

Creates a TextAnnotation from JSON.

Implementation

factory TextAnnotation.fromJson(Map<String, dynamic> json) {
  final type = json['type'] as String;
  return switch (type) {
    'file_citation' => FileCitationAnnotation.fromJson(json),
    'file_path' => FilePathAnnotation.fromJson(json),
    _ => throw FormatException('Unknown annotation type: $type'),
  };
}