i've been trying to make a listview in flutter and get how many pixels the view had scrolled. Unfortunately, i used NotificationListener
Like this:
NotificationListener<ScrollUpdateNotification>(
child: ListView(
children: [
//content here
],
),
onNotification: (notification) {
//How many pixels scrolled from pervious frame
// print("scrollDelta: ${notification.scrollDelta}");
setState(() {
this.scrollValue = notification.metrics.pixels;
});
//List scroll position
// print("metrics.pixels: ${notification.metrics.pixels}");
return true;
},
),
Issue is that it gave some very poor performance with my application.
So i noticed that you could use a controller directly with the ListView and i made the following code:
ScrollController controller;
controller.addListener(() {
print("i'm here");
});
var scaffold = Scaffold(
backgroundColor: Color(0xFFFFFFFF),
resizeToAvoidBottomPadding: false,
body: Stack(
children: [
ListView(
controller: controller,
children: [
//content here
],
),
],
),
);
But then i get the following error :
NoSuchMethodError: invalid member on null: 'addListener'
I currently have no idea how to get how many pixel were scrolled in a listview without hindering greatly the performances.