My app has a permanent view (home) witch has an appbar + drawer + bottom navigation bar when I click on bottom navigation bar items it replaces the body content of home with one of the pages (page1, page2, page3, page4)
It's all working well but now I have a button in page2 that loads subPage and as result I only have the content of subPage without the permanent view of home so no appbar or drawer or bottom navigation bar
Haw can I do to make the button target the body part of my permanent view
Here is a simplified code: Home.dart is a stateful widget...
int _currentIndex = 0;
List<Widget> _pages = [
Page1(),
Page2(),
Page3(),
Page4(),
];
Route _onRoute(RouteSettings settings) {
final str = settings.name.split("/")[1];
final index = int.parse(str, onError: (s) => 0);
return new MaterialPageRoute(
builder: (BuildContext context) => new Page1(index: index));
}
@override
Widget build(BuildContext context) {
Column(
children: <Widget>[
new Expanded(
child: new MaterialApp(
onGenerateRoute: _onRoute,
home: new Scaffold(
body: _pages[_currentIndex],
appBar: new AppBar(
drawer: Drawer()
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex,
onTap: (int index) {
setState(() {
_currentIndex = index;
});
},
items: [...]
page3.dart: a stateless widget that return a container of listview
.
.
.
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Subpage()));
},
what should I do or put in the ontap to target the body of home