当我使用 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();
}
Run Code Online (Sandbox Code Playgroud)
这就是我构建 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)
);
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,列表项没有被点击。但是如果我用 ListView 替换 ListWheelScrollView ,如下所示,它可以完美运行。
@override …Run Code Online (Sandbox Code Playgroud)