1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Adds trivia to Veggie details screen (#61)

This commit is contained in:
Andrew Brogdon
2019-03-22 08:32:44 -07:00
committed by GitHub
parent dcca6e44b2
commit 526ee0602a
5 changed files with 306 additions and 15 deletions

View File

@@ -33,6 +33,14 @@ enum Season {
autumn,
}
class Trivia {
final String question;
final List<String> answers;
final int correctAnswerIndex;
const Trivia(this.question, this.answers, this.correctAnswerIndex);
}
const Map<VeggieCategory, String> veggieCategoryNames = {
VeggieCategory.allium: 'Allium',
VeggieCategory.berry: 'Berry',
@@ -67,6 +75,7 @@ class Veggie {
@required this.vitaminCPercentage,
@required this.servingSize,
@required this.caloriesPerServing,
@required this.trivia,
this.isFavorite = false,
});
@@ -80,7 +89,7 @@ class Veggie {
final VeggieCategory category;
/// A short, snappy line, possibly with trivia.
/// A short, snappy line.
final String shortDescription;
/// A color value to use when constructing UI elements to match the image
@@ -108,5 +117,8 @@ class Veggie {
/// as a favorite).
bool isFavorite;
/// A set of trivia questions and answers related to the veggie.
final List<Trivia> trivia;
String get categoryName => veggieCategoryNames[category];
}