I have 4 Scrollable Widget in my page 1 Vertical (Main) and 3 Horizontal.
And 2 Scrollable Widgets (1 vertical & 1 horizontal) trigger parallax animation for background.
How can i detect which Scrollable widget is dispatching ScrollNotification.
Here's the example:
class MYPage extends StatefulWidget {
MYPage({Key key}) : super(key: key);
@override
_MYPageState createState() => _MYPageState();
}
class _MYPageState extends State<MYPage> {
double scrollX = 0.0;
double scrollY = 0.0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
ParallaxBackground(scrollX, scrollY),
Positioned.fill(
child: NotificationListener<ScrollNotification>(
onNotification: (notification) {
double scrollOffset = notification.metrics.pixels;
setState(() {
if (notification.metrics.axis == Axis.horizontal) {
this.scrollX = scrollOffset;
} else {
this.scrollY = scrollOffset;
}
});
return true;
},
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Content(),
HorizontalScrollableContent(),
Content(),
HorizontalScrollableContentWithParallaxControl(),
Content(),
HorizontalScrollableContent(),
Content(),
],
),
),
),
),
],
),
);
}
}