NativeSurface.fromJson constructor

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

The surface toJson wrote, for rendering a reply's text.

Implementation

factory NativeSurface.fromJson(Map<String, Object?> json) => NativeSurface(
      kind: SurfaceKind.values.where((k) => k.name == json['kind']).firstOrNull ?? SurfaceKind.unknown,
      title: json['title'] as String?,
      choices: [
        for (final c in (json['choices'] as List? ?? const []).cast<Map<String, Object?>>())
          (text: '${c['text']}', id: '${c['id']}', x: 0, y: 0),
      ],
      texts: [for (final t in json['texts'] as List? ?? const []) '$t'],
      owner: json['owner'] as String?,
    );