https://github.com/CantC0unt/RecipeCalculator/blob/master/lib/recipe.dart
GitHub – CantC0unt/RecipeCalculator: Flutter에 내장된 간단한 앱입니다.
홍수로 만든 간단한 앱. GitHub에서 계정을 생성하여 CantC0unt/RecipeCalculator 개발에 기여하십시오.
github.com
위의 계산기가 복제되었습니다.
저번에 만든 계산기와 거의 똑같습니다.
한 번 입력된 레시피 양
슬라이더 값이 변경될 때 추가해야 하는 레시피를 변경하는 계산기입니다.
인덱스 관련 오류가 발생했는데 모델에 입력된 값의 순서와 UI에서 값의 순서가 달라서 문제가 발생한 것으로 보입니다.

모델 클래스
class Recipe {
String name;
int servings;
List<Ingredient> ingredients=();
Recipe(this.name,this.servings,this.ingredients);
static List<Recipe>data=(
Recipe("Chocolate Chip Cookies", 36, (
Ingredient(1, "cup", "Salted Butter", "softened"),
Ingredient(1, "cup", "white sugar", "granulated"),
Ingredient(1, "cup", "light brown sugar", "packed"),
Ingredient(2, "tsp", "pure vanilla extract", ""),
Ingredient(2, "", "large eggs", ""),
Ingredient(3, "cups", "all-purpose flour", ""),
Ingredient(1, "tsp", "baking soda", ""),
Ingredient(0.5, "tsp", "baking powder", ""),
Ingredient(1, "tsp", "sea salt", ""),
Ingredient(
2, "cups", "chocolate chips", "or chunks, or chopped chocolate")
)),
);
}
class Ingredient{
double amount;
String unit;
String item;
String additional;
Ingredient(this.amount,this.unit,this.item,this.additional);
}