pizzaplanner/lib/entities/PizzaRecipe/Ingredient.dart
2021-08-29 15:37:21 +02:00

37 lines
No EOL
875 B
Dart

import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:pizzaplanner/util.dart';
part 'Ingredient.g.dart';
@HiveType(typeId: 1)
class Ingredient extends HiveObject {
@HiveField(0)
String name;
@HiveField(1)
String unit;
@HiveField(2)
double value;
@HiveField(3)
bool bought = false;
Ingredient(this.name, this.unit, this.value);
TableRow getIngredientTableRow(int pizzaCount, int doughBallSize){
return TableRow(
children: <Widget>[
TableCell(child: Center(child: Text("${this.name.capitalize()}"))),
TableCell(child: Center(child: Text("${this.getAbsolute(doughBallSize)}$unit"))),
TableCell(child: Center(child: Text("${this.getAbsolute(pizzaCount * doughBallSize)}$unit"))),
],
);
}
int getAbsolute(int weight) {
return (this.value * weight).toInt();
}
}