gpt4 book ai didi

android - 如何为图标勾勒颜色,但您也可以填充颜色 [Flutter]

转载 作者:行者123 更新时间:2023-12-05 00:02:04 25 4
gpt4 key购买 nike

嗨,我想做的是制作一个类似于此文本示例的堆叠图标类型:

Stack(
children: <Widget>[
Text(
widget.news.title,
style: TextStyle(
fontSize: 20,
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 2
..color = Colors.black,
),
),
Text(
widget.news.title,
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
],
),
所以我的目标是为后向箭头图标(添加了 SilverAppBar)添加一个带有白色轮廓的琥珀色填充,但现在我只能访问 iconTheme,如下所示:
iconTheme: IconThemeData(
color: Colors.white,
),
所以我的问题如下:我怎样才能让 SilverAppBar 以这种方式着色的后退箭头图标
输出图像:
As you can see he text has a small outline around it I wish that Icon had it as well
小部件部分代码:
return <Widget>[
SliverAppBar(
pinned: true,
expandedHeight: 200,
title: Stack(
children: <Widget>[
Text(
widget.news.title,
style: TextStyle(
fontSize: 20,
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 2
..color = Colors.black,
),
),
Text(
widget.news.title,
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
],
),
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
widget.news.urlToImage,
fit: BoxFit.fill,
errorBuilder: (context, error, StackTrace) {
return Image(
fit: BoxFit.cover,
image: AssetImage("images/placeholder_details.png"),
);
},
),
),
)
];
期待听到你的意见:D

最佳答案

尝试了多种解决方案,效果很好。
使用icon_decoration像这样:

DecoratedIcon(
icon: Icon(Icons.arrow_back, color: Colors.white),
decoration: IconDecoration(border: IconBorder()),
)

关于android - 如何为图标勾勒颜色,但您也可以填充颜色 [Flutter],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70942333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com