在抖动中填充水平滚动视图

时间:2020-11-01 23:18:23

标签: flutter listview dart

如何检索以下格式的数据,然后将其传递到水平项目列表中。

数据格式

"suggestion": {
      "add_food": {
        "Red": [
          {
            "Calcium": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Choline": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Copper": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Iodine": [
              "Amaranth, grain, whole, uncooked",
              "Apricot, dried"
            ]
          },
          {
            "Iron": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Manganese": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Niacin (B3)": [
              "Apple, fuji, unpeeled, raw",
              "Apple, golden delicious, unpeeled, raw"
            ]
          },
          {
            "Omega-3 excl. ALA and SDA": [
              "Bass, fillet, raw",
              "Beef Brain"
            ]
          },
          {
            "Pantothenic acid (B5)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Phosphorus": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Protein": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Riboflavin (B2)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Thiamin (B1)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Vitamin D": [
              "Beef kidney, raw",
              "Beef liver, raw"
            ]
          },
          {
            "Vitamin E": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Zinc (Zn)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Crude fat": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Folate": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Magnesium": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Sodium (Na)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ],
        "Yellow": [
          {
            "Omega-6": [
              "Amaranth, grain, whole, uncooked",
              "Avocado, raw"
            ]
          },
          {
            "Potassium": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ]
      },
      "remove_food": {
        "Red": [
          {
            "Selenium": [
              "Cheese, cottage, unflavoured, no salt"
            ]
          }
        ],
        "Yellow": [
          {
            "Vitamin A": [
              "Cheese, cottage, unflavoured, no salt",
              "Cream, sour, regular fat"
            ]
          }
        ]
      }
    },

我需要获取“ add_food”和“ remove_food”的值, 并分别根据颜色值“红色”或“黄色”在其上添加文本颜色。 还获取该颜色值内的数据,并在以下视图中相应显示它们。 我在遍历以上格式时有些困惑。 我可以将视图调整为以下一种。但是在弄清楚如何通过这种数据格式进行迭代时需要一些指导。

desired list view

0 个答案:

没有答案