Complete the code to wrap the ListTile with a Dismissible widget.
return Dismissible( key: Key(items[index]), child: [1]( title: Text(items[index]), ), );
The Dismissible widget needs a child widget to display. Here, ListTile is the correct child to show each item.
Complete the code to remove the item from the list when dismissed.
onDismissed: (direction) {
setState(() {
items.[1](index);
});
},removeAt(index) removes the item at the given index from the list.
Fix the error by completing the code to provide a background widget for swipe action.
background: Container( color: Colors.[1], alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 20), child: Icon(Icons.delete, color: Colors.white), ),
The background color red is commonly used to indicate delete action on swipe.
Fill both blanks to complete the Dismissible widget with a unique key and swipe direction.
Dismissible( key: Key(items[[1]]), direction: DismissDirection.[2], child: ListTile(title: Text(items[index])), onDismissed: (direction) { setState(() { items.removeAt(index); }); }, )
The key must be unique per item, so using index is correct. The swipe direction startToEnd allows swipe from left to right.
Fill all three blanks to create a Dismissible with a red background, swipe from right to left, and remove item on dismiss.
Dismissible( key: Key(items[[1]]), background: Container( color: Colors.[2], alignment: Alignment.centerRight, padding: EdgeInsets.only(right: 20), child: Icon(Icons.delete, color: Colors.white), ), direction: DismissDirection.[3], child: ListTile(title: Text(items[index])), onDismissed: (direction) { setState(() { items.removeAt(index); }); }, )
Use index for unique key, red color for delete background, and endToStart for swipe from right to left.