Last active
August 18, 2018 04:40
-
-
Save IshanFx/56ec9bc5c4130267ff6d07ca46bf0841 to your computer and use it in GitHub Desktop.
Swipe to delete without icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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