flutterflutter-scaffold

is it possible to navigate or change the body of current page with new page and i dont want to change the app bar in flutter


I am Currently using the scaffold, and inside that, I have a tab bar, and in that tab bar, I have two tabs, product one and product two, and I have a button inside the page one page, and when I click on that button, it will redirect me to the Product three page, but I don't want to change the app bar, i.e., I want to only render the page three content over the page one, and if I press the back button, then the page one should again occur via page three. I want the solution for this rendering or navigation thing.


Solution

  • you can use bloc package to change state of your widget

     Scaffold(
       appBar:AppBar(), 
       body:
        BlocBuilder<MyPagebloc, MyPageState>( 
           builder: (context, state) {
            if(state.page1) 
              return Page1();
           else 
              return Page3();
           }
        )
    

    and to change state

    context.read<MyPagebloc>().add(someEvent);