I have a ListView and a Calendar above it. My plan is to expend the Calendar based on the ListView scroll state. I managed to handle all of that except one issue with Android.
ScrollController _scrollController;
@override
void initState() {
super.initState();
_scrollController = ScrollController();
_scrollController.addListener(_handleScroll);
}
@override
void dispose() {
_scrollController.removeListener(_handleScroll);
_scrollController.dispose();
super.dispose();
}
void _handleScroll() {
// Handle Scrolling here.
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Calendar(),
Expanded(
child: ListView(
controller: _scrollController,
padding: EdgeInsets.only(bottom: 10),
children: <Widget>[
ListViewItem(),
ListViewItem(),
...
],
),
),
],
),
);
}
The image below illustrate the issue!
As you can see, pulling the ListView when the user didn't scroll down yet doesn't seem to trigger the _handleScroll at all. I think it's by design on Android. Any solutions or workaround to this will be much appreciated.
Solution 1: INDAPP
You must use a CustomScrollView with Slivers, as explained here: https://flutter.dev/docs/cookbook/lists/floating-app-bar