Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter navigation bar

Tags:

flutter

dart

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()
      ]
    ),
  );
}
like image 446
Dani Kovács Avatar asked Mar 23 '18 09:03

Dani Kovács


People also ask

How do you make a navigation bar in flutter?

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.

What is navigation bar in flutter?

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.

How do you keep the bottom navigation bar in flutter?

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.


1 Answers

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,
    ),
  ),
like image 71
Rémi Rousselet Avatar answered Oct 15 '22 16:10

Rémi Rousselet