【问题标题】:Bottom Navigation Bar is completely white, how to fix?底部导航栏完全是白色的,如何修复?
【发布时间】:2019-11-13 15:03:05
【问题描述】:

我的BottomNavigationBar 完全是白色的。当有3 图标时它工作正常,但当增加到4 时,导航栏完全变白。仍然可以选择和更改选项卡。

这是小部件运行时控制台的输出。

ic=null mNaviBarColor -15724014 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false

这是导航栏的构建:

_bottomNavChildren[_currentIndex],
  bottomNavigationBar: BottomNavigationBar(
    onTap: onTabTapped,
    currentIndex: _currentIndex,
    items: [
      BottomNavigationBarItem(
        icon: Icon(Icons.search),
        title: Text('Browse'),
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.message),
        title: Text('Messages'),
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.person_outline),
        title: Text('Profile'),

这是指向相关索引类的List 小部件。

  int _currentIndex = 0;
  final List<Widget> _bottomNavChildren = [
    BrowsePage(),
    MessagesPage(),
    ProfilePage(),
  ];

有人知道是什么问题吗? 谢谢

【问题讨论】:

    标签: flutter dart navigationbar


    【解决方案1】:

    来自飘飘official documentation

    BottomNavigationBarType.fixed,有小于时默认 四项。所选项目使用 selectedItemColor 呈现 如果它是非空的,否则主题的 ThemeData.primaryColor 是 用过的。如果 backgroundColor 为空,导航栏的背景 颜色默认为材质背景颜色 ThemeData.canvasColor (基本上是不透明的白色)。

    BottomNavigationBarType.shifting,默认时有四个或 更多项目。如果 selectedItemColor 为 null,则所有项目都呈现在 白色的。导航栏的背景颜色与 所选项目的BottomNavigationBarItem.backgroundColor。在这个 假设每个项目都有不同的背景 颜色和背景颜色将与白色形成鲜明对比。

    【讨论】:

    • 对。为type 添加BottomNavigationBarType.fixed 解决了它。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-09
    • 2014-05-24
    • 2020-12-27
    • 2017-09-13
    • 1970-01-01
    • 2019-12-16
    相关资源
    最近更新 更多