private void _handleDelete(LeaveBehindItem item) { setState(() => { leaveBehindItems.Remove(item); }); _scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Text($"You deleted item {item.index}"), action: new SnackBarAction( label: "UNDO", onPressed: () => { handleUndo(item); } ) )); }
private int lowerBound(List <LeaveBehindItem> items, LeaveBehindItem item) { items.Sort(); for (int i = 0; i < items.Count; i++) { if (item.CompareTo(items[i]) >= 0) { return(i); } } return(items.Count - 1); }
public _LeaveBehindListItem( Key key = null, LeaveBehindItem item = null, onArchiveFunc onArchive = null, onDeleteFunc onDelete = null, DismissDirection?dismissDirection = null, bool?confirmDismiss = null ) : base(key: key) { this.item = item; this.onArchive = onArchive; this.onDelete = onDelete; this.dismissDirection = dismissDirection; this.confirmDismiss = confirmDismiss; }
private void handleUndo(LeaveBehindItem item) { int insertionIndex = lowerBound(leaveBehindItems, item); setState(() => { leaveBehindItems.Insert(insertionIndex, item); }); }