Flutter 吐槽下BottomNavigationBarItem的问题.

前言

打算flutter仿个掘金玩玩, 这不刚开始,就碰到问题了.

问题

正常的底部按钮是这样的

bottomNavigationBar: new BottomNavigationBar(
        items: [
          new BottomNavigationBarItem(
            icon: Icon(Icons.home),
            title: new Text("123"),
          ),
          new BottomNavigationBarItem(
            icon: Icon(Icons.whatshot),
            title: new Text("123"),
          ),
          new BottomNavigationBarItem(
            icon: Icon(Icons.search),
            title: new Text("123"),
          ),
          new BottomNavigationBarItem(
            icon: Icon(Icons.book),
            title: new Text("123"),
          ),
          new BottomNavigationBarItem(
            icon: Icon(Icons.person),
            title: new Text("123"),
          ),
        ],
复制代码

掘金呢.是没有文字的.

于是我就想当然的把title去掉.

然后.

好吧,title不能为null

但是!

这里根本没有声明是必传的好吗?

然后看

这里又做校验了..真是.

设置一个空的Text

  new BottomNavigationBarItem(
            icon: Icon(Icons.person),
            title: new Text(''),
          ),
复制代码

不行,没居中.

实际上,你需要这样:

 new BottomNavigationBarItem(
            icon: Icon(Icons.person),
            title: new Container(),
          ),
复制代码

但是,强迫症写起来总觉得怪怪的.这个title不需要为啥一定要设置

去github上看flutter 的issuse.#17099

好像没有改的打算.

这个东西嘛,自己去重写一个感觉也没必要,真是..


期待你的留言 点赞
交流群:

Flutter:782978118

Android:493180098

转载于:https://juejin.im/post/5ce3b052518825330f7279eb

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值