'How to outline color an icon but that you can fill the color as well [Flutter]
Hi what I want to do is make a stacked Icons type similar to this example for Text:
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,
),
),
],
),
So what my goal is to have an amber colored fill with white outline for backarrow icon (added with SilverAppBar), but for now I was only able to access the iconTheme as follow:
iconTheme: IconThemeData(
color: Colors.white,
),
So my question is as follow: How can I have back arrow icon with SilverAppBar colored that way
Output Image:
The Widget part code:
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"),
);
},
),
),
)
];
Looking forward to hear your opinion :D
Solution 1:[1]
Tried out multiple solutions, and this works perfectly.
Use icon_decoration like this:
DecoratedIcon(
icon: Icon(Icons.arrow_back, color: Colors.white),
decoration: IconDecoration(border: IconBorder()),
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nagulan S |

