Reputation: 13
I was able to do this using offset But I ran into a problem I have variable sizes of items and they change, so I didn't know the exact size to do this
final ScrollController _scrollController = ScrollController();
String _appBarTitle = "Hello Amir";
@override
void initState() {
super.initState();
_scrollController.addListener(_scrollListener);
}
void _scrollListener() {
double offset = _scrollController.offset;
double section1Start = 1;
double section2Start = 550;
double section3Start = 1100;
setState(() {
if (offset < section1Start) {
_appBarTitle = "Hello Amir";
} else if (offset >= section1Start && offset < section2Start) {
_appBarTitle = "The first part";
} else if (offset >= section2Start && offset < section3Start) {
_appBarTitle = "The second part";
}
});
}
Upvotes: 0
Views: 55