
The current implementation will throw an exception if 'question' or 'options' fields are missing in the YAML data. To make the parsing more robust and prevent potential server crashes from malformed content, consider handling null values by providing defaults (e.g., an empty string for the question and an empty list for options).
Question parseQuestion(YamlMap map) {
return Question(
parseMarkdownToHtml((map['question'] as String?) ?? '', inline: true),
((map['options'] as List<Object?>?) ?? [])
.map((e) => parseAnswer(e as YamlMap))
.toList(),
);
}
最初由 @gemini-code-assist[bot] 在 dart-lang/site-www#7085 (comment) 发布
The current implementation will throw an exception if 'question' or 'options' fields are missing in the YAML data. To make the parsing more robust and prevent potential server crashes from malformed content, consider handling null values by providing defaults (e.g., an empty string for the question and an empty list for options).
最初由 @gemini-code-assist[bot] 在 dart-lang/site-www#7085 (comment) 发布