Skip to content

Instantly share code, notes, and snippets.

@IshanFx
Last active August 18, 2018 04:40
Show Gist options
  • Save IshanFx/56ec9bc5c4130267ff6d07ca46bf0841 to your computer and use it in GitHub Desktop.
Save IshanFx/56ec9bc5c4130267ff6d07ca46bf0841 to your computer and use it in GitHub Desktop.
Swipe to delete without icons
class SwipeWidget extends State<SwipeList> {
List items = getDummyList();
@override
Widget build(BuildContext context) {
return Container(
child: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return Dismissible(
key: Key(items[index]),
onDismissed: (direction) {
setState(() {
items.removeAt(index);
});
},
child: Container(
height: 50.0,
decoration: BoxDecoration(border: Border.all(width: 1.0)),
padding: EdgeInsets.all(5.0),
child: Row(
children: <Widget>[
Text(
items[index],
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
),
)
],
),
),
);
},
));
}
static List getDummyList(){
List list = List.generate(10, (i) {
return "Item ${i +1 }";
});
return list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment