Here's the code.
Widget build(BuildContext context) {
return StreamBuilder<List<Widget>>(
stream: _getMealsViewWidgets(weekNum),
builder: (BuildContext context, AsyncSnapshot<List<Widget>> snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
return Center(child: CircularProgressIndicator());
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
}
if (snapshot.error != null) {
return Center(child: Text('Error occurred.'));
}
if (snapshot.connectionState == ConnectionState.done) {
return PageView(children: snapshot.data, controller: _pageController);
}
return Center(child: CircularProgressIndicator());
});
}
The PageView has fix 7 pages. I'd like to jump after a refresh to a specific page. The problem is because the PageView is a return of a StreamBuilder I can't call the pagecontroller.jumpPage method after the refresh. How can I jump to a specific page after return?
Have you tried using
WidgetsBinding.instance.addPostFrameCallback((_) {
// executes after build
})
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.