【发布时间】:2021-09-29 15:30:59
【问题描述】:
在这里您可以看到我的 Reorderable ListView 的屏幕截图,所有尾随图标都是绿色的,因为我悬停其中一个:
我希望当我将鼠标悬停在 ListTile 的尾随图标上时,只有这个图标会改变颜色,而不是列表的所有尾随图标,
我可能需要实现一个索引,但不知道如何使它工作,这是我的代码:
List<Tache> listeTaches = [
new Tache("Tache1", "Projet1"),
new Tache("Tache2", "Projet2"),
new Tache("Tache3", "Projet3")
];
_onReorder(oldIndex, newIndex) {
setState((){
if(newIndex > oldIndex){
newIndex -= 1;
}
var item = listeTaches.removeAt(oldIndex);
listeTaches.insert(newIndex, item);
});
}
var my_color = Colors.grey;
var onEntered = false;
_updateIcon(_){
setState(() {
if (onEntered == false){
onEntered = true;
my_color = Colors.green;
} else {
onEntered = false;
my_color = Colors.grey;
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: LightColors.kLightYellow,
appBar: AppBar(
leading: Container(
child: MyBackButton(),
padding: EdgeInsets.only( left: 30),
),
title: Text('Terminé', style: TextStyle(color: Colors.black),),
centerTitle: true,
backgroundColor: LightColors.kBlue,
),
body: ReorderableListView(
buildDefaultDragHandles: false,
header: Center(
child: Container(
child: Text(
'Listes des tâches',
style: Theme.of(context).textTheme.headline5,
),
padding: EdgeInsets.symmetric(vertical: 20)
)
),
children: listeTaches.map((e) => ListTile(
key: UniqueKey(),
leading: Icon(BeoticIcons.disc),
title: Text(e.nom),
subtitle: Text(e.nomProjet),
trailing: MouseRegion(onHover: _updateIcon,
child: Icon(BeoticIcons.circle_check, color: my_color)
)
)).toList(),
onReorder: _onReorder
)
);
}
感谢您的帮助!
【问题讨论】:
标签: list flutter indexing hover icons