我的产品列表包含类别ID,我需要在新列表中获得相同类别的所有产品
我在Flutter中为两个API都进行了建模,效果很好,我需要遍历产品以使所有产品都属于我使用过的redux类别的选定ID
如何将类别ID与产品中的字段类别进行比较
产品
"results": [
{
"id": 2,
"name": "Lactoni sport",
"name_ar": "",
"description": "Lactoni sport",
"description_ar": "",
"images": [
{
"id": 1,
"product": "http://192.168.2.3:8000/api/products/2/",
"thumbnail": "http://192.168.2.3:8000/media/product-thumbnails/a3logo.png"
}
],
"price": "333.00",
"weight": "",
"offer": "",
"categories": [
1
],
"sub_categories": [],
"supplier": []
},
{
"id": 3,
"name": "Nike",
"name_ar": "",
"description": "nike shoes",
"description_ar": "",
"images": [
{
"id": 2,
"product": "http://192.168.2.3:8000/api/products/3/",
"thumbnail": "http://192.168.2.3:8000/media/product-thumbnails/18-420_Nike_Paul_George_3_Heroes_04_Surface-02_rectangle_1600_GAiQk1O.jpg"
}
],
"price": "45.00",
"weight": "",
"offer": "",
"categories": [
1
],
"sub_categories": [],
"supplier": []
},
]
类别
"results": [
{
"id": 1,
"category": "sport",
"category_ar": "sport",
"image": "http://192.168.2.3:8000/media/category-images/A31.png",
"sequence": 1
},
{
"id": 2,
"category": "meat",
"category_ar": "meat",
"image": "http://192.168.2.3:8000/media/category-images/IntlMeatCo-217_1-Bone-In-Ribeye.jpg",
"sequence": 3
},
{
"id": 3,
"category": "Milk",
"category_ar": "milk",
"image": "http://192.168.2.3:8000/media/category-images/images.jpeg",
"sequence": 4
},
]```