I am trying to change the border color and also the text label color of an Outline button but I am getting errors. What is the best way to achieve this?
OutlinedButton(
onPressed: null,
color: Colors.orange,
style: ButtonStyle(
shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0))),
side: BorderSide(width: 5.0, color: Colors.blue),
),
child: const Text("Crime"),
),
3
Answers
This is answered here https://stackoverflow.com/a/57874637/15598475
For some reason, my answer needs to be at least 30 characters so I am writing some nonsense 🙂
Set the
style
of the button as:side
parameter inOutlinedButton.styleFrom
.foregroundColor
inOutlinedButton.styleFrom
.In the above example, the
red
is the border color, and theblue
is the text color.To change the border color and text label color of an
OutlinedButton
, you can adjust thestyle
property of the button. Here’s how you can achieve this:In this code:
side
property ofButtonStyle
allows you to specify the border side, where you can set the color to change the border color.foregroundColor
property allows you to specify the color of the text label.