1. Dismissible позволяет легко реализовать логику swipe-to-delete.
Dismissible(
key: Key(item.id),
background: Container(color: Colors.red),
onDismissed: (direction) => deleteItem(item.id),
child: ListTile(
title: Text("Swipe me to delete"),
),
)
2. Tooltip показывает краткую подсказку при долгом нажатии (mobile) или наведении (web/desktop).
Tooltip(
message: 'Download PDF',
child: IconButton(
icon: Icon(Icons.download),
onPressed: () {},
),
)
3. Draggable подходит, чтобы реализовать drag-and-drop, как в Trello или корзине интернет-магазина.
Draggable<Color>(
data: Colors.blue,
feedback: Container(
height: 100,
width: 100,
color: Colors.blue.withOpacity(0.5),
),
childWhenDragging: Container(
height: 100,
width: 100,
color: Colors.grey,
),
child: Container(
height: 100,
width: 100,
color: Colors.blue,
),
);
4. ReorderableListView идеально подходит для настроек, плейлистов и любых кастомных списков.
ReorderableListView(
onReorder: (oldIndex, newIndex) {
setState(() {
if (newIndex > oldIndex) newIndex -= 1;
final item = list.removeAt(oldIndex);
list.insert(newIndex, item);
});
},
children: list
.map(
(item) => ListTile(
key: ValueKey(item),
title: Text(item.toString()),
),
)
.toList(),
);
А какими виджетами для UX чаще всего пользуетесь вы? Делитесь в комментариях.
