how do i disable click on particular item in list view
108
define your own child widget for list view item as follow:
Widget myWidget (String date, String isEnable){
return RaisedButton(onPressed: isEnable=="1"?YourFunction:()=>{}, child: Text(date),);
}
the use in ListView.builder
as follow:
return ListView.builder(itemBuilder: (ctx, idx){
return myWidget(yourList[idx]["date"], yourList[idx]["click"]);
}, itemCount: yourList.length,)
where yourList
is the given list in your question. Also, you can use any form of widget instead of RaisedButton, it is just an example!
Author by
john math
Updated on December 31, 2022Comments
-
john math about 1 year
i want to disable click on some items in list view , from api i can get some list of item
like
[ { "date": "1", "click": "1" }, { "date": "2", "click": "0" }, { "date": "3", "click": "1" }, { "date": "4", "click": "0" }, { "date": "5", "click": "2" } ]
I want to disable
onclick
with flutter ifclick = 0