Reputation: 43
Hi all assume there are three pages A,B,c in bottom navigation bar and there is a button in A when pressed it navigate to screen D Im still able to see bottom navigation bar here please help me to solve this P
Upvotes: 3
Views: 3785
Reputation: 61
Like @Skander answer, using RootNavigator on the "of" method should do the trick.
Navigator.of(context, rootNavigator: true).push(...);
Here is the description of rootNavigator option, according to documentation:
If rootNavigator is set to true, the state from the furthest instance of this class is given instead. Useful for pushing contents above all subsequent instances of Navigator.
Upvotes: 1
Reputation: 141
i had the same problem and i found that rootNavigator:true
solve it
Navigator.of(context,rootNavigator: true).push(...);
Upvotes: 11
Reputation: 373
Make your screen D as StatefulWidget. For example:
class ScreenD extends StatefulWidget {
@override
State createState() => new ScreenDState();
}
class ScreenDState extends State<ScreenD> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return new Scaffold();
}
}
Mark your screen A as StatefulWidget too same with screen D. Then a button in screen A onPressed handler housed in BottomNavigationBar:
Navigator.push(context, MaterialPageRoute(builder: (context) => ScreenD()),);
It should remove the BottomNavigationBar when screen D renders.
Upvotes: 0