问题描述
我想写一些更复杂的东西,但为了简化问题,我写了一个简短的例子来反映我的问题的本质:
Widget build(BuildContext context) {
return NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
print("up"); //Todo
return true;
},child: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
print("down"); //Todo
return true;
},child: SingleChildScrollView(
controller: horizontalScroll,scrollDirection: Axis.horizontal,child: Container(
width: 2000,child: Scaffold(
body: Container(
color: Colors.lightBlueAccent,child: ListView.builder(
controller: verticalScroll,itemCount: 30,itemBuilder: (context,index) {
return Container(
height: 30,color: Colors.lightBlueAccent,child: Text("Line " + index.toString()),);
})),))),),);
}
我的目标:两个 NotificationListener 都应该在任何子滚动小部件中捕获滚动事件,但实际上我看到只有 print("down") 被触发。如何解决问题,使滚动事件到达两个 NotificationListener?我无法将它们组合起来,因为在实际项目中,它们是两个不同的小部件。此外,这个项目曾经可以工作,直到我尝试将所有内容更新为空安全,也许这就是问题
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)