Skip to content

Instantly share code, notes, and snippets.

@NITIN-ME

NITIN-ME/main.dart

Created Jun 30, 2020
Embed
What would you like to do?
class Person extends StatelessWidget {
Person({this.name, this.cb, this.idx});
final String name;
final func cb;
final int idx;
@override
Widget build(BuildContext context) {
//RandomColor _randomColor = RandomColor();
//Color _color = _randomColor.randomColor(colorBrightness: ColorBrightness.light);
return Container(
//decoration: BoxDecoration(color: _color),
child: Dismissible(
key: Key(name),
background: Container(
color: Colors.green,
padding: EdgeInsets.symmetric(horizontal: 10),
alignment: AlignmentDirectional.centerStart,
child: Icon(Icons.check_box),
),
secondaryBackground: Container(
color: Colors.redAccent,
padding: EdgeInsets.symmetric(horizontal: 10),
alignment: AlignmentDirectional.centerEnd,
child: Icon(Icons.backspace),
),
onDismissed: (DismissDirection d){
if(d == DismissDirection.startToEnd){
//print("Add");
cb(idx);
lst.add(name);
print(lst);
}
else{
cb(idx);
//print("Delete");
}
},
child: ListTile(
leading: CircleAvatar(child: Text(name[0]),),
title: Text(name, style: TextStyle(fontWeight: FontWeight.w800)),
)),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment