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

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

问题描述

我想在收到新消息时在BottomNavigationBar的 Icon 图标的右上角上显示通知徽章(彩色的大理石)已到达收件箱标签。它类似于 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?

推荐答案

是。可以通过使用 Stack Positioned 小部件来堆叠两个图标来完成。

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),
            )
          ]
        ),
      )

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

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