I want to make swipable image viewer and have InteractiveViewer
inside PageView.builder
.
class PageViewImageSwiper extends StatelessWidget {
final List<Image> images;
const PageViewImageSwiper({required this.images, super.key});
@override
Widget build(BuildContext context) {
// Need logic to make it true when two or more fingers on the screen
bool _swipeDisabled = false;
return Scaffold(
body: Column(
children: [
Expanded(
child: PageView.builder(
physics: _swipeDisabled ? NeverScrollableScrollPhysics() : null,
itemBuilder: (context, count) => InteractiveViewer(
child: images[count],
),
),
)
],
));
}
}
But they conflicting and i want to disable PageView scroll when have two fingers on the screen.
2
Answers
Solved problem by adding
Listener
Here is a sample code on how to detect two fingers on the screen:
The main juice is the
_handleScaleUpdate
, as you can tell how many pointer events are on the screen from the pointer count of the scale update details.