2

I have problems when displaying 2 PageViews on 1 screen it seems. Below is my app: the calendar weeks timeline is PageView and content below it also needs to be PageView.

screenshot

Now both PageViews need to talk to each other - when scrolling bottom content pageview I want upper view to change white circle selection, and finally flip the page, when coming to the end.

So I use

calendarPageView.controller.jumpToPage(pageForDate);

(or nextPage() method) and this is what I get:

The page property cannot be read when multiple PageViews are attached to the same PageController. package:flutter/src/widgets/page_view.dart': Failed assertion: line 101 pos 7: 'positions.length == 1

It seems they for some reason use the same PageController? Any thoughts how to solve it?

1
  • Just putting it out here if anyone comes here: i just needed to hot restart my app and the error went... seems like some debug cache issue :) Commented Jan 31 at 12:59

1 Answer 1

7

I figgured it out! :) For your sake, make sure you construct your PageView with creating it's own instance of PageController, e.g.:

new PageView.builder(
   ...,
   controller: new PageController()
);

So you don't run into this issue. It seems that by default PageViews share the controller for some reason.

Not the answer you're looking for? Browse other questions tagged or ask your own question.