在底部导航栏的图标上显示通知徽章 [英] Displaying notification badge on BottomNavigationBar's Icon

查看:35
本文介绍了在底部导航栏的图标上显示通知徽章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在收到新消息时在底部导航栏的图标小部件的右上角上显示通知徽章(彩色大理石)已到达收件箱选项卡.它类似于 https://developer.android.com/preview/features/notification-badges.html 但就我而言,它显示在应用程序中.

I'd like to display notification badge (a colored marble) on the top right corner of BottomNavigationBar's Icon widget when a new message has arrived in the inbox tab. It is similar to https://developer.android.com/preview/features/notification-badges.html but for my case it is displayed in-app.

在现有图标上绘制叠加层以创建自定义图标类的任何提示?

Any tips to paint the overlay on existing icon to create a custom Icon class?

推荐答案

是的.这可以通过使用 StackPositioned 小部件堆叠两个图标来完成.

Yes. It can be done by stacking two icons using the Stack and Positioned widget.

      new BottomNavigationBarItem(
        title: new Text('Home'),
        icon: new Stack(
          children: <Widget>[
            new Icon(Icons.home),
            new Positioned(  // draw a red marble
              top: 0.0,
              right: 0.0,
              child: new Icon(Icons.brightness_1, size: 8.0, 
                color: Colors.redAccent),
            )
          ]
        ),
      )

这篇关于在底部导航栏的图标上显示通知徽章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆