0

I use three TabBarView in my project with wantKeepAlive in every TabBarView, but the second tabBarView will dispose when i jump view from one to three。However when I switch to other widget which like fragment in Android , all the TabBarView will dispose,I cant't find anyone have the same problem just like me.Thanks First.

the second TabBarView dispose

enter image description here

and this is my code

body: new TabBarView(controller: _tabController, children: <Widget>[
    new EventsView(
      presenter: _presenter,
      key: Key("EventsView"),
    ),
    new HistoryView(
      presenter: _presenter,
      key: Key("HistoryView"),
    ),
    new NewsView(
      key: Key("NewsView"),
      presenter: _presenter,
    ),
  ]),

and if i select the drawer item

Widget build(BuildContext context) {
return Scaffold(

    body: Builder(builder: (BuildContext context) {
      this.scaffoldContext = context;
      return _getFromIndex(position);
    }));
}



_getFromIndex(int i) {
    if (i == 0) {
          return _dashboard();
    } else if (i == 1) {
          return new TeamView(key: Key("TeamView"),);
    } else if (i == 2) {
          return AllBookView();
    } else if (i == 3) {
          return AllDocView();
    }
}
Ashish
  • 6,791
  • 3
  • 26
  • 48
yami
  • 63
  • 1
  • 6
  • https://stackoverflow.com/questions/49439047/how-to-preserve-widget-states-in-flutter-when-navigating-using-bottomnavigation?rq=1 – Mazin Ibrahim May 11 '19 at 06:54
  • I have add bool get wantKeepAlive => true with super.build(context) in my all tabBarView – yami May 11 '19 at 12:04

0 Answers0