cleaned up some code things for the ingredients table

This commit is contained in:
broodjeaap89 2021-07-11 11:17:39 +02:00
parent 4ad9db0fdf
commit 77dd896fcd
3 changed files with 21 additions and 23 deletions

View file

@ -9,7 +9,7 @@ class Ingredient {
Ingredient(this.name, this.unit, this.value); Ingredient(this.name, this.unit, this.value);
TableRow getIngredientWidget(int pizzaCount, int doughBallSize){ TableRow getIngredientTableRow(int pizzaCount, int doughBallSize){
return TableRow( return TableRow(
children: <Widget>[ children: <Widget>[
TableCell(child: Center(child: Text("${this.name.capitalize()}"))), TableCell(child: Center(child: Text("${this.name.capitalize()}"))),

View file

@ -7,9 +7,8 @@ class Ingredients {
Ingredients(this.ingredients, this.method); Ingredients(this.ingredients, this.method);
Widget getIngredientsWidget(int pizzaCount, int doughBallSize) { Table getIngredientsTable(int pizzaCount, int doughBallSize) {
return Container( return Table(
child: Table(
border: TableBorder.all(), border: TableBorder.all(),
columnWidths: const <int, TableColumnWidth>{ columnWidths: const <int, TableColumnWidth>{
0: FlexColumnWidth(2), 0: FlexColumnWidth(2),
@ -27,8 +26,7 @@ class Ingredients {
) )
] + ] +
ingredients.values.map((ingredient) => ingredient.getIngredientWidget(pizzaCount, doughBallSize)).toList() ingredients.values.map((ingredient) => ingredient.getIngredientTableRow(pizzaCount, doughBallSize)).toList()
)
); );
} }
} }

View file

@ -17,7 +17,7 @@ class PizzaRecipe {
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps); PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
Widget getIngredientsWidget(int pizzaCount, int doughBallSize){ Widget getIngredientsWidget(int pizzaCount, int doughBallSize){
return ingredients.getIngredientsWidget(pizzaCount, doughBallSize); return ingredients.getIngredientsTable(pizzaCount, doughBallSize);
} }
static Future<PizzaRecipe> fromYaml(yamlPath) async{ static Future<PizzaRecipe> fromYaml(yamlPath) async{