当前位置:网站首页>Fluent generates icon prompt logo widget
Fluent generates icon prompt logo widget
2022-07-05 10:10:00 【cppphp】
Sometimes in order to provide users with some additional status , Often in Icon The corner of the is displayed with additional icons , Such as the common digital red dot logo , We don't implement the red dot logo today , Instead, use a smaller Icon Make prompt logo , To show some other States , Such as “ Mushroom meter ”app One of them IconButton There is a logo in the upper left corner and the upper right corner of the button respectively to indicate that the timing record and the alarm record have been opened . The example is as follows :

Flutter There is no ready-made Icon Prompt logo Widget, Of course, it can be implemented with a third-party library , But it is not always convenient to use ready-made wheels , In fact, it's very simple to realize this function . Just use Stack and Positioned It can be done easily , The code is as follows :
/// Generate badged Icon
/// icondata - IconData type , contain Icon Icon data
/// sups - List<IconData?> type , Include superscript Icon An array of icon data
/// color - Color type , Specify the superscript badge color
Widget supIcon(IconData icondata, List<IconData?> sups,{color=Colors.yellow}) {
List<Widget> _pos = [Icon(icondata)];
for (var i = 0; i < sups.length; i++) {
if (sups[i] != null) {
_pos.add(
Positioned(
top: i == 0 || i == 1 ? -6.0 : null,
left: i == 0 || i == 3 ? -6.0 : null,
right: i == 1 || i == 2 ? -6.0 : null,
bottom: i == 2 || i == 3 ? -6.0 : null,
child: Icon(
sups[i],
size: 16,
color: color,
)),
);
}
}
return Stack(
clipBehavior: Clip.none,
children: _pos
);
}
The code is simple , But realized the logo of four corners . The calling code is also relatively simple , There is no art here .
边栏推荐
- Officially launched! Tdengine plug-in enters the official website of grafana
- 程序员如何活成自己喜欢的模样?
- 高级 OpenCV:BGR 像素强度图
- Wechat applet - simple diet recommendation (3)
- ArcGIS Pro 创建要素
- Small program startup performance optimization practice
- 写入速度提升数十倍,TDengine 在拓斯达智能工厂解决方案上的应用
- The essence of persuasion is to remove obstacles
- C#函数返回多个值方法
- Generics, generic defects and application scenarios that 90% of people don't understand
猜你喜欢

Coordinate system of view

QT event filter simple case

Roll up, break 35 - year - old Anxiety, animation Demonstration CPU recording Function call Process

Analysis on the wallet system architecture of Baidu trading platform

分布式数据库下子查询和 Join 等复杂 SQL 如何实现?

Kotlin compose and native nesting

Windows uses commands to run kotlin

Small program startup performance optimization practice

Evolution of Baidu intelligent applet patrol scheduling scheme

To bring Euler's innovation to the world, SUSE should be the guide
随机推荐
MySQL字符类型学习笔记
[200 opencv routines] 219 Add digital watermark (blind watermark)
Node red series (29): use slider and chart nodes to realize double broken line time series diagram
How to get the STW (pause) time of GC (garbage collector)?
一种用于干式脑电图的高密度256通道电极帽
How to use sqlcipher tool to decrypt encrypted database under Windows system
How to implement complex SQL such as distributed database sub query and join?
百度智能小程序巡檢調度方案演進之路
QT event filter simple case
90%的人都不懂的泛型,泛型的缺陷和应用场景
Tdengine already supports the industrial Intel edge insight package
Pagoda panel MySQL cannot be started
善用兵者,藏于无形,90 分钟深度讲解最佳推广价值作品
Tdengine can read and write through dataX, a data synchronization tool
[C language] the use of dynamic memory development "malloc"
Cross process communication Aidl
Cut off 20% of Imagenet data volume, and the performance of the model will not decline! Meta Stanford et al. Proposed a new method, using knowledge distillation to slim down the data set
Resolve the horizontal (vertical) sliding conflict between viewpager and WebView
Understand the window query function of tdengine in one article
Node-RED系列(二九):使用slider与chart节点来实现双折线时间序列图