AIM: I wish to make my flutter app also on the web, hence, like most websites, I want it to have an AppBar
that is always there no matter how many screens (routes) I push or where I navigate.
PROBLEM: However, when I do Navigator.push()
, the AppBar
disappears, since a new Scaffold
is created with it’s own AppBar
.
QUESTION: Is there any way to achieve a constant AppBar
in my flutter app?
WHAT I TRIED: I tried using IndexedStack
, which worked for my main screens. However, when I want to navigate from one of my main screens (which are in the indexed stack), this approach fails.
2
Answers
Edit
sorry, the above doesn’t work so here is the solution:
use
MyPage
as a template to any of your pages.the
Hero
widget is to keep the app bar at place in route transitionsYou can use bottomNavigationBar parameter of the Scaffold() widget,
or you can use another creative alternative like this: