I just started app developing and im struggling with navigation bar. The bottom one is good but the one at the top is not. I want to remove the grey space above the buttons.
Can you help me?
Code:
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
backgroundColor: Colors.grey,
bottom: new TabBar(
controller: controller,
tabs: <Tab>[
new Tab(icon: new Icon(Icons.arrow_forward)),
new Tab(icon: new Icon(Icons.arrow_downward)),
new Tab(icon: new Icon(Icons.arrow_back)),
]
)
),
body: new TabBarView(
controller: controller,
children: <Widget>[
new first.First(),
new second.Second(),
new third.Third(),
new fourth.Fourth(),
new fifth.Fifth()
]
),
);
}
In Flutter application, we usually set the bottom navigation bar in conjunction with the scaffold widget. Scaffold widget provides a Scaffold. bottomNavigationBar argument to set the bottom navigation bar. It is to note that only adding BottomNavigationBar will not display the navigation items.
Navigation bars offer a persistent and convenient way to switch between primary destinations in an app. This widget does not adjust its size with the ThemeData.
One of the solutions could be to use the property withNavBar and toggle it according to the Platform. In platform-specific behavior, while pushing a new screen, on Android it will push the screen WITHOUT the bottom navigation bar but on iOS it will persist the bottom navigation bar.
Don't use Appbar
then. Use a Card
with an elevation of 26.0. As what you want is a custom appbar:
final tab = new TabBar(tabs: <Tab>[
new Tab(icon: new Icon(Icons.arrow_forward)),
new Tab(icon: new Icon(Icons.arrow_downward)),
new Tab(icon: new Icon(Icons.arrow_back)),
]);
return new Scaffold(
appBar: new PreferredSize(
preferredSize: tab.preferredSize,
child: new Card(
elevation: 26.0,
color: Theme.of(context).primaryColor,
child: tab,
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With