這是我的演示 json 回應。假設我想顯示所有資料,"CategoryList但我不顯示"CategoryName": "NEW ARRIVALS",我的應用程式中的串列。如何忽略來自我的 Json 回應的特定資料?我可以按關鍵字過濾掉New嗎?
如果New關鍵字進入CategoryName將忽略整個串列
{
"Status": 1,
"Message": "",
"CategoryList": [
{
"CategoryId": "2",
"CategoryName": "Women",
"CategoryImage": "https://ductImage/vkzvquiex2747i.jpg",
"CategoryNote": "Satin Night Suits For Women",
"SubCategoryList": [
{
"CategoryId": "2",
"CategoryName": "Women",
"SubCategoryId": "10",
"SubCategoryName": "Satin & Lace",
"SubCategoryImage": "https://oductImage/cxb1920565muxxb.jpg",
"SubCategoryNote": "Ultra chic sophisticated & easy-breezy Collection"
},
{
"CategoryId": "2",
"CategoryName": "Women",
"SubCategoryId": "16",
"SubCategoryName": "Bathrobe",
"SubCategoryImage": "https://ProductImage/19eprae16hd3vqc.jpg",
"SubCategoryNote": "Super-soft Bathrobe's for cosy moments at home."
},
{
"CategoryId": "2",
"CategoryName": "Women",
"SubCategoryId": "39",
"SubCategoryName": "Bedroom Slippers",
"SubCategoryImage": "https:///ProductImage/bpq1tb8g2mawc18.jpg",
"SubCategoryNote": "Leisure home room slippers."
}
]
},
{
"CategoryId": "12",//========Want to ignore where `CategoryId": "12`==========
"CategoryName": "NEW ARRIVALS",
"CategoryImage": "https://oductImage/wq35lbuzanbpzh.jpg",
"CategoryNote": "Custom Designed & Exclusive Night Wears",
"SubCategoryList": [
{
"CategoryId": "12",
"CategoryName": "NEW ARRIVALS",
"SubCategoryId": "45",
"SubCategoryName": "New Arrivals For Women",
"SubCategoryImage": "https://n/ProductImage/llwyc6wiky73jts.jpg",
"SubCategoryNote": "My night My Style with Customized Women Night Suit"
},
{
"CategoryId": "12",
"CategoryName": "NEW ARRIVALS",
"SubCategoryId": "46",
"SubCategoryName": "New Arrivals For Men",
"SubCategoryImage": "https://in/ProductImage/1pj9oyq0zpgfu9c.jpg",
"SubCategoryNote": "Comfortable Customizable Men night Suites "
},
{
"CategoryId": "12",
"CategoryName": "NEW ARRIVALS",
"SubCategoryId": "47",
"SubCategoryName": "New Arrivals For Kids",
"SubCategoryImage": "https://.in/ProductImage/norg12vhysn5fbm.jpg",
"SubCategoryNote": "Be Fashionable, be divine, be yourself and Shine"
}
]
},
{
"CategoryId": "13",
"CategoryName": "Bedsheet",
"CategoryImage": "https://ductImage/r9eqe10ltoxqxo.jpg",
"CategoryNote": "Cotton Rich Printed Bedsheets",
"SubCategoryList": [
{
"CategoryId": "13",
"CategoryName": "Bedsheet",
"SubCategoryId": "50",
"SubCategoryName": "Bedsheet",
"SubCategoryImage": "https://roductImage/e8wigvfgulr15j5.jpg",
"SubCategoryNote": "Ultrafine Cotton BedSheet "
}
]
},
]
}
我的 Ui 部分在我的應用程式螢屏中顯示資料。
FutureBuilder(
future: AllCategories_SubCat(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return Center(
child:
// Lottie.network(
// 'https://assets1.lottiefiles.com/packages/lf20_YMim6w.json'));
CupertinoActivityIndicator());
}
if (snapshot.hasError) {
return Text(
"Somthing went wrong. Please try after some time.");
}
if (snapshot.hasData) {
return ListView.builder(
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) =>
Padding(
padding:
EdgeInsets.only(left: blockSizeHorizontal * 5),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
Sub_categories_page(
snapshot.data[index])));
},
child: SizedBox(
//width: blockSizeHorizontal * 68,
width: getProportionateScreenWidth(180),
height: blockSizeVertical * 15,..........
..........
.........
uj5u.com熱心網友回復:
您可以將此過濾器應用于串列,然后再將其發送給構建器
categoryList.removeWhere((element) => element.CategoryId == '12');
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/409979.html
標籤:
上一篇:顫振,GetXinitState
