The named parameter 'onScrollNotification' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'onScrollNotification'.dartundefined_named_parameter
时间: 2024-01-17 14:05:36 浏览: 48
Flutter 中的 `ListView` 并不支持 `onScrollNotification` 参数,因此您在使用 `ListView` 的时候会遇到此错误。
如果您需要在滚动时监听 `ListView` 的滚动事件,可以使用 `ScrollController` 和 `NotificationListener`。以下是示例代码:
```dart
ScrollController _controller = ScrollController();
NotificationListener(
onNotification: (notification) {
if (notification is ScrollUpdateNotification) {
// 滚动更新通知
} else if (notification is ScrollEndNotification) {
// 滚动结束通知
}
return true;
},
child: ListView.builder(
controller: _controller,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
// 子组件
},
),
);
```
在上面的代码中,我们使用了 `ScrollController` 来控制 `ListView` 的滚动,并使用 `NotificationListener` 来监听滚动事件。通过监听通知类型的不同,我们可以处理不同类型的滚动事件。