当我使用 ListView 时,ListTile OnTap 正在工作。但是当我使用 ListWheelScrollView 时它不起作用。我的意思是它不会被窃听。观点发生变化。但我似乎无法点击它。我在很多地方和链接中寻找解决方案,但仍然找不到解决方案。
这些是我所做的代码。
@override
Widget build(BuildContext context) {
return new ListWheelScrollView(
physics:FixedExtentScrollPhysics(),
children: getPostList(),
itemExtent: 100.0,
);
}
List<PostListItem> getPostList() {
return _postModal
.map((contact) => new PostListItem(contact))
.toList();
}
这就是我构建 ListTile 的地方
@override
Widget build(BuildContext context) {
return new ListTile(
onTap: () {
var route = new MaterialPageRoute(
builder: (BuildContext context) =>
new OnTapPost(value: _postModal.fullName),
);
Navigator.of(context).push(route);
},
leading: new Image.asset('assets/images/logo.png'),
title: new Text(_postModal.fullName),
subtitle: new Text(_postModal.email)
);
}
在上面的代码中,列表项不会被点击。但是,如果我将 ListWheelScrollView 替换为 ListView(如下所示),则它可以正常工作。
@override
Widget build(BuildContext context) {
return new ListView(
children: getPostList(),
);
}
List<PostListItem> getPostList() {
return _postModal
.map((contact) => new PostListItem(contact))
.toList();
}