I'm trying to add Chips to the ListTile subtitle, so that when the listTile is created via a ListView.builder, depending on the user's selection, they can have or see multiple chips in the subtitle.
ListView.builder(
scrollDirection: Axis.vertical,
itemCount: myShoppingBasketList.length,
itemBuilder: (ct, shoppingListViewBuilderItemInteger)
{
return Card(
child: ListTile(key: UniqueKey(),
//dense: true,
leading: ...,
title: ...
subtitle: Wrap(<add chips here)...
onTap: ()
{
// Code to add new chips depending on selection
}
})
So - how could I dynamically += add to a Wrap widget. When I say
+=
What I'm hoping for is that if a Chip was like a String, then I'd like something like:
Wrap(SomeChipContainerWidget = SomeChipContainerWidget+ newChipWidget))
Do you see my problem??
So let's say the subTitle was a Text widget, then the String text inside could be:
Text(stringVar += stringVar + newString)
I have tried EVERYTHING - You cannot imagine. I've looked at Expansion Tiles - does't work, Animated, etc..
Any help will be really appreciated. Even sympathy.
Declare a List and add a Chip to the List as per your requirement.
Example Code:
List<Chip> chips = []; // Global Variable (Add a chip by default)
[...]
ListView.builder(
scrollDirection: Axis.vertical,
itemCount: myShoppingBasketList.length,
itemBuilder: (ct, shoppingListViewBuilderItemInteger)
{
return Card(
child: ListTile(key: UniqueKey(),
//dense: true,
leading: [...],
title: [...]
subtitle: Wrap(children: <Widget>[chips])...
onTap: ()
{
setState((){
chips.add(
Chip() //Your new chip
);
});
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.