I would like to create a scrollable list that has borders at the top and at the button but only when the list’s content “overflows” in the corresponding direction. So:
- when the list fits entirely into the available space: no borders.
- when the list doesn’t fit and
- overflows at the bottom: a bottom border is shown.
- overflows at the top: a bottom border is shown.
- overflows at the top and the bottom: both a top and a bottom border are shown.
I tried something like that:
build() {
bool showTop = scrollController.offset > 0;
bool showBottom = scrollController.position.minScrollExtent != scrollViewController.position.maxScrollExtent;
return Stack(
children: [
ListView(controller: scrollController, builder: (){
// build children
}),
if(showTop) buildTop(),
if(showBottom) buildBottom(),
]
);
}
But I receive a “ScrollController not attached to any scroll views.” exception. Which makes sense but also makes me wonder how I could achieve the desired effect.