Flutter如何修改Awesome Notifications通知图标背景颜色
修改Awesome Notifications通知图标背景色的方法
针对你要修改通知图标绿色背景的需求,有两种常用方案:
1. 自定义单个通知的样式
在调用通知时添加customClass参数,然后通过CSS覆盖对应样式:
调用示例(Vue版本)
this.$notification.success({ title: '操作成功', message: '内容已保存', customClass: 'custom-success-notification' })
对应CSS
.custom-success-notification .an-icon-wrapper { background-color: #your-target-color; /* 替换为你需要的颜色值 */ }
2. 全局修改所有同类型通知的样式
如果要统一修改所有成功类型(success)通知的图标背景,直接覆盖默认类选择器:
.an-notification.an-success .an-icon-wrapper { background-color: #your-target-color; }
注意事项
- 确保你的CSS代码加载顺序在Awesome Notifications的默认样式之后,避免被覆盖
- 如果样式优先级不够,可以增加选择器的特异性(比如加上父容器类),尽量避免使用
!important
内容的提问来源于stack exchange,提问作者Mat Koffman
相关产品推荐
相关产品推荐

