【发布时间】:2020-08-13 02:36:37
【问题描述】:
我有一个 FutureBuilder - ListView.builder,是否可以显示列表中的每个项目?
我使用过不透明度、可见性小部件,但两者都可以同时工作。 我只是想在我按下一件特定的东西时看到这一点。 提前致谢。
bool visible = false;
FutureBuilder(
builder: (context, snap) {
return ListView.builder(
shrinkWrap: true,
itemCount: snap.data.length,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
Voca voca = snap.data[index];
return GestureDetector(
onLongPress: () => visible = !visible,
onLongPressEnd: (details) => visible = !visible,
key: Key(snap.data[index].toString()),
child: Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 1.2,
color: Colors.black
.withOpacity(0.3)))),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: <Widget>[
Text(voca.word,
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w700,
color: Colors.black)),
SizedBox(height: 2),
Row(children: <Widget>[
Visibility(
visible: visible,
child: Text(voca.meaning,
style: TextStyle(
fontSize: 17,
fontWeight:
FontWeight.w500,
color: Colors.black.withOpacity(0.7)))),
));
});
}
},
future: loadVoca()
)
【问题讨论】: