I've just recently gotten into flutter and am loving it so far but I've gotten stuck on some UI changes. Any help is appreciated!
My goal is to get a circular button that has an icon with a blue background but then have a border around the outside that is a darker blue. There are pictures attached.
My approach was:
- Get a circular blue button.
- Put an icon in that button.
- Add a border.
I got stuck on step 3 because I do not know how to add a border, or if it is even possible given the way I approached the problem. The specific colors do not matter to me at the moment, I will change the theme later.
This is what I currently have code wise:
var messageBtn = new Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(20.0),
child: new RawMaterialButton(
onPressed: _messages,
child: new Padding(
padding: const EdgeInsets.all(20.0),
child: new Icon(
Icons.message,
size: 30.0,
color: Colors.white,
),
),
shape: new CircleBorder(),
fillColor: Colors.deepPurple,
),
),
new Padding(
padding: const EdgeInsets.all(8.0),
child: new Text(
'Send Messages',
style: new TextStyle(
fontSize: 20.0,
),
)),
],
);
It produces this: see screenshot
I want this:see second screenshot
Hi Kathleen and welcome!
You can achieve what you want by diving a little deeper into the widgets that make up
MaterialButton
.First you need the Ink widget. This offers more flexible styling using a BoxDecoration.
Ink
can then contain an InkWell widget which recognisesonTap
and draws the splash effect. By default, the splash continues to the edges of the containing box, but you can make it circular by givingInkWell
a really bigborderRadius
.Here's an example of the button you're after:
And here's the result: