flutter - 颤振:获取css:在图像应用背景的效果之后
问题描述
我有 CSS 规则来为图像添加背景有一个白色背景,如下所示
.product-img:after {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(40,44,63,.05);
content: '';
background-blend-mode: overlay;
}
结果 [![在此处输入图像描述][3]][3]
想要快速获得相同的效果,我尝试了几个小部件,如 Stack、Position,
但无法达到相同的效果。
我的图像加载小部件:
FadeInImage(
image: NetworkImage(
"my-url"
),
placeholder: AssetImage('assets/images/load_fut.png'),
),
解决方案
Seems your images have solid white background. So to display on top of white background need to play bit with blendmode to achieve desired effect. Here is output close to what you're trying to achieve.
Update : Using cached_network_image
Add Depednecy
cached_network_image: ^2.2.0+1
@override
_ColorPageState createState() => _ColorPageState();
}
class _ColorPageState extends State<ColorPage> {
@override
Widget build(BuildContext context) {
return
CachedNetworkImage(
height: 200,
width: 400,
colorBlendMode: BlendMode.darken,
color: Color.fromARGB(20, 40, 44, 63),
imageUrl:
"https://tacskey.com/image/cache/catalog/categories/Cold%20Cuts/chicken-nuggets-600x350.jpg",
placeholder: (context, url) => Image.asset(
'assets/loader_.png',
height: 50,
width: 50,
),
errorWidget: (context, url, error) => Icon(Icons.error),
);
}
}
Output gif :
推荐阅读
- cmake - CMake 多配置生成器使用错误的构建目录
- jquery - 如何在 JQuery Query Builder 中模拟全局运算符?
- flutter - 如何使颤动显示完整的文本
- javascript - 检查身份验证后反应组件未呈现
- java - 如何在 Nativescript-angular 中使用 Java 的内部匿名类?
- python - Python中的值错误,代码在某些地方失败
- html - 我对 numpad jquery 有疑问。我希望用户输入显示在用户单击小键盘的位置
- python - 如何将 pandas.core.series.Series 转换为 Dataframe?
- pandas - 如何从日期时间中提取一天中的时间(pd.Timedelta 或 datetime.time)?
- javascript - 将图像从直接消息媒体附加到 Twitter 状态