pagecotroller错误滚动滚动器附加到多个滚动视图
我有这样的类:
class MyController {
static PageController globalController = PageController(initialPage: 0);
void diispose() {
globalController.dispose();
}
}
我想在两个不同的位置使用此pagecontroller
来修改pageview
但是,使用后myController.globalcontroller.jumptopage(1);
我遇到了此错误:
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
package:flutter/…/widgets/scroll_controller.dart:1
Failed assertion: line 108 pos 12: '_positions.length == 1'
I have a class like this :
class MyController {
static PageController globalController = PageController(initialPage: 0);
void diispose() {
globalController.dispose();
}
}
I'd like to use this PageController
in two different locations to modify thePageView
however after use MyController.globalController.jumpToPage(1);
I got this error :
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
package:flutter/…/widgets/scroll_controller.dart:1
Failed assertion: line 108 pos 12: '_positions.length == 1'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不能将相同的pagecontroller用于两个滚动视图,但是您可以为每个滚动创建一个和一个将所有滚动滚动到页面的方法,如下所示:
I think you cannot use the same PageController for two scroll views, but you can create one for each scroll and one method that jump all scrolls to page, as the example below: