Flutter——最详细(Badge)使用教程

news/2024/7/7 18:43:37 标签: flutter

背景

主要常用于组件叠加上圆点提示;
使用场景,消息数量提示,消息红点提示

属性作用
backgroundColor红点背景色
smallSize设置红点大小
isLabelVisible是否显示
offset设置红点位置
alignment设置红点位置
child设置底部组件

代码块

class BadgePage extends StatelessWidget {
  const BadgePage({Key? key}) : super(key: key);

  
  Widget build(BuildContext context) {
    return const Wrap(
      spacing: 20,
      children: [
        Badge(
          backgroundColor: Colors.redAccent,
          smallSize: 10,
          child: Icon(Icons.update,size: 36,color: Colors.blue,),
        ),
        Badge(
          backgroundColor: Colors.redAccent,
          smallSize: 10,
          label: Text('99'),
          isLabelVisible: false,
          largeSize: 14,
          child: Icon(Icons.update,size: 36,color: Colors.blue,),
        ),
        Badge(
          backgroundColor: Colors.redAccent,
          smallSize: 10,
          label: Text('99'),
          largeSize: 14,
          child: Icon(Icons.update,size: 36,color: Colors.blue,),
        ),
        Badge(
          backgroundColor: Colors.red,
          label: const Text('99'),
          smallSize: 20,
          textStyle: const TextStyle(fontSize: 8, color: Colors.red),
          padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
          largeSize: 14,
          offset:  Offset(-4, -4),
          alignment: Alignment.bottomRight,
          child: const Icon(Icons.message, size: 36, color: Colors.indigo),
        ),
      ],
    );
  }
}

效果图

在这里插入图片描述


http://www.niftyadmin.cn/n/5534904.html

相关文章

复分析——第8章——共形映射(E.M. Stein R. Shakarchi)

第8章 共形映射(Conformal Mappings) The results I found for polygons can be extended under very general assumptions. I have undertaken this research because it is a step towards a deeper understanding of the mapping problem, for which not much has hap…

鸿蒙登录页面及页面跳转的设计

目录 任务目标任务分析任务实施1.新建工程项目HMLogin2.设计登录页面Index.visual3.设计第二个页面SecondPage4.修改Index.ets代码5.修改SecondPage.ets代码6.运行工程 任务目标 设计一个简单的登录页面,要求可以将第一页的登录信息,传递到第二个页面&a…

办公软件WPS与Office的区别

临近计算机考试很多同学在纠结我是报wps好?还是ms office好?下面就来详细说说。 1、wps属于国内金山公司的办公软件,里面包含word、Excel和PPT。考试是2021年开始的! 2、MS(Microsoft 微软) office属于美…

【pytorch13】激活函数及梯度

什么是激活函数 计算机科学家借鉴生物的神经元机制发明了计算机上的模型,这个模型与生物的神经元非常类似 激活的意思就是z变量要大于0,这一个节点才会激活,否则就会处于睡眠状态不会输出电平值 该激活函数在z0处不可导,因此不能…

STM32工业自动化控制系统教程

目录 引言环境准备工业自动化控制系统基础代码实现:实现工业自动化控制系统 4.1 数据采集模块 4.2 数据处理与分析 4.3 控制系统实现 4.4 用户界面与数据可视化应用场景:工业自动化与优化问题解决方案与优化收尾与总结 1. 引言 工业自动化控制系统利用…

MySQL之备份与恢复(四)

备份与恢复 存储引擎和一致性 3.复制 从备库中备份最大的好处是可以不干扰主库,避免在主库上增加额外的负载。这是一个建立备库的好理由,即使不需要用它做负载均衡或高可用。如果钱是个问题,也可以把备份用的备库用于其他用户,…

高级Redis之Stream的用法示例

不想自己搭建一个mq怎么办?Redis的Stream 来帮你,Redis Stream 是 Redis 5.0 引入的一种新的数据结构,用于处理实时的、可持久化的、基于时间序列的数据流。它非常适合处理事件流、日志、消息队列等场景。下面是一个使用 Redis Stream 的具体…

CSS-position/transform

1 需求 2 语法 在CSS中,positioning 和 transform 是两个非常重要的概念,它们分别用于控制元素在页面上的布局和变换。 Positioning CSS中的position属性用于设置元素的定位类型。它有几个值,包括: static:这是默认…