Using this with Scrollable widgets like PageView
Hi Serge! How it is possible to using pdf viewer with Scrollable widgets? How example, if vertical pdf viewers puts in horizontal PageView pages, functionality may got broken. If pdf was zoomed before, PageView's horizontal drag gesture wins, and page get scrolled insteadof moving zoomed pdx image Any ideas?
any workaround on this?
It seems that single page PDF works fine with PageView, however multi page PDF breaks the PageView left/right swipe scrollable behavior.
We use PageView like that:
final pageView = PageView.builder(
itemBuilder: (context, index) {
return pdfWidget;
},
physics: const FastScrollPhysics(speedFactor: 4.0),
controller: _pageController,
itemCount: pdfs.length,
);
class FastScrollPhysics extends PageScrollPhysics {
final double speedFactor;
const FastScrollPhysics({this.speedFactor = 2.0, ScrollPhysics? parent}) : super(parent: parent);
@override
FastScrollPhysics applyTo(ScrollPhysics? ancestor) {
return FastScrollPhysics(
speedFactor: speedFactor,
parent: buildParent(ancestor),
);
}
@override
Simulation? createBallisticSimulation(
ScrollMetrics position,
double velocity,
) {
return super.createBallisticSimulation(position, velocity * speedFactor);
}
}
Unfortunately that doesn't work with multi page PDFs. E.g. when swiping right, the subsequent PDFs page are opened, but when user reaches the end the further swipe doesn't do anything, where in fact it should trigger scroll to next PageView page. Conversely when swiping left and reaching the beginning of the PDF, PageView doesn't go to the previous item.