MessagePrompt.fromJson constructor

MessagePrompt.fromJson(
  1. Object? j
)

Implementation

factory MessagePrompt.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return MessagePrompt(
    context: switch (json['context']) {
      null => '',
      Object $1 => decodeString($1),
    },
    examples: switch (json['examples']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Example.fromJson(i)],
      _ => throw const FormatException('"examples" is not a list'),
    },
    messages: switch (json['messages']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Message.fromJson(i)],
      _ => throw const FormatException('"messages" is not a list'),
    },
  );
}