비용 계산기 클론 코딩

https://github.com/CantC0unt/RecipeCalculator/blob/master/lib/recipe.dart

위의 계산기는 클론입니다.

저번에 만든 계산기와 비슷합니다.

레시피의 양을 한번 입력하세요

슬라이더의 값이 변함에 따라 추가해야 하는 레시피를 변경하는 계산기입니다.

인덱싱 관련 오류가 있었는데, 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);


}