flutter/Dart : Customize Bottom Navigation Bar height

标签 flutter dart

有没有办法自定义 BottomNavigationBar 的高度?

我目前有一个 BottomNavigationBar,带有用于点击/滑动导航的选项卡,但是默认高度(即使在减少文本和图标之后)还是太高了。

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    backgroundColor: Colors.blue,
    title: Text( 'RefLog', style: Styles.headerLarge ),
    actions: <Widget>[
      new IconButton(
        icon: Icon(Icons.list),
        onPressed: () {},
      )
    ],
  ),
  body: DefaultTabController(
    length: 3,
    child: Scaffold(
      body: TabBarView(
        children: _children,
      ),
      bottomNavigationBar: TabBar(
        tabs: [
          Tab( text: 'One', icon: Icon(Icons.import_contacts, size: 20.0) ),
          Tab( text: 'Two', icon: Icon(Icons.restaurant, size: 20.0) ),
          Tab( text: 'Three', icon: Icon(Icons.record_voice_over, size: 20.0) ),
        ],
        labelStyle: TextStyle(fontSize: 12.0),
        labelColor: Colors.white,
        unselectedLabelColor: Colors.white30,
        indicatorSize: TabBarIndicatorSize.label,
        indicatorColor: Colors.white,
      ),
      backgroundColor: Colors.blue,
    ),
  ),
 );
}

最佳答案

你可以通过 SizedBox 包装 bottomNavigationBar,

bottomNavigationBar: SizedBox(height: 58, child: //some widget )

关于 flutter/Dart : Customize Bottom Navigation Bar height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53758698/

相关文章:

firebase - 遍历 Firestore 集合求和值的文档的最佳方法是什么?

flutter - 如何将 flutter 应用程序中的帖子分享到 linkedIn、facebook 等社交媒体平台?

string - 如何在 Dart 中反转包含代理对的字符串?

flutter - 如何保存页面的状态

flutter - 如何在Flutter中初始化文本字段

dart - 在 flutter 中创建卡片和标题

flutter - Listview 不会在列中呈现

listview - 在 flutter ListView 中检测焦点小部件

flutter - “此表达式的类型为 'void',因此无法使用其值。” setState()错误抖动

asynchronous - Flutter/Dart - 调用一个 Future<String> 的函数......但只需要返回一个 String