0

show data with the header as subCatName and subheader as catItems as mentioned in JSON response :

"data": {
        "menuItems": [
            {
                "catId": 15,
                "catName": "Alcoholic Beverages",
                "catImage": "",
                "subCat": [
                    {
                        "subCatName": "Whisky",
                        "catItems": [
                            {
                                "id": 15,
                                "itemName": "Canadian Whisky",
                                "itemImage": "699231783852538944.jpeg",
                                "description": "Like scotch, Canadian whisky must be barrel-aged for at least three years. It’s lighter and smoother than other types of whiskey because it contains a high percentage of corn.",
                                "itemType": 0,
                                "price": 1900,
                                "isCustomized": 0,
                                "subCatName": "Whisky",
                                "discountPrice": 0,
                                "discount": 0,
                                "happyHourPrice": 0,
                                "type": 0,
                                "finalPrice": 1900,
                                "label": "",
                                "unitPricing": []
                            },
                            {
                                "id": 14,
                                "itemName": "Irish Whiskey",
                                "itemImage": "1789148815801946357.jpeg",
                                "description": "It’s made from a mash of malt, can only be distilled using water and caramel coloring, and must be distilled in wooden casks for at least three years.",
                                "itemType": 0,
                                "price": 1500,
                                "isCustomized": 0,
                                "subCatName": "Whisky",
                                "discountPrice": 0,
                                "discount": 0,
                                "happyHourPrice": 0,
                                "type": 0,
                                "finalPrice": 1500,
                                "label": "",
                                "unitPricing": []
                            },                            ]
                    }
                ]
            },
            {
                "catId": 16,
                "catName": "Non-alcoholic Beverages",
                "catImage": "",
                "subCat": [
                    {
                        "subCatName": "Beverages",
                        "catItems": [
                            {
                                "id": 16,
                                "itemName": "Soft Drinks",
                                "itemImage": "3305072142819356183.jpg",
                                "description": "The origins of soft drinks lie in the development of fruit-flavored drinks.",
                                "itemType": 0,
                                "price": 700,
                                "isCustomized": 0,
                                "subCatName": "Beverages",
                                "discountPrice": 0,
                                "discount": 0,
                                "happyHourPrice": 0,
                                "type": 0,
                                "finalPrice": 700,
                                "label": "",
                                "unitPricing": []
                            }
                        ]
                    }
                ]
            },
        ]
    }

enter image description here

Want to show Whisky, Beverages in the header cell with related catItems. How to do so in a single listview builder with cell action? New to flutter. Tried to apply the sliver list but not worth it as it gave the wrong index on adding items to the cart.

Diksha235
  • 442
  • 7
  • 17

0 Answers0