Reputation: 578
I have added a border to my TextButton.
TextButton(
style: ButtonStyle(
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0)))),
onPressed: () {
replacePoints();
},
child: Text(
"${AppLocalizations.of(context)!.replacePoints} +",
style: TextStyle(color: Colors.white),
))
How can I change its colour (only outline colour not background)?
Upvotes: 3
Views: 4415
Reputation: 14885
Try below code you will change Border color in two ways
Using TextButton.styleFrom
refer styleFrom
TextButton(
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.green,
),
),
onPressed: () {
//write your onPressed function here
print('Button Press');
},
child: Text(
'Hello, World!',
style: Theme.of(context).textTheme.headline4,
),
),
Using ButtonStyle
Class refer ButtonStyle
TextButton(
style: ButtonStyle(
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
side: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(5),
),
),
),
onPressed: () {
//write your onPressed function here
print('Button Press');
},
child: Text(
'Hello, World!',
style: Theme.of(context).textTheme.headline4,
),
),
Upvotes: 2
Reputation: 3475
Try this:
TextButton(
style: ButtonStyle(
shape: MaterialStateProperty.all(RoundedRectangleBorder(
side: BorderSide(
color: Colors.red, // your color here
width: 1,
),
borderRadius: BorderRadius.circular(0)))),
onPressed: () {
replacePoints();
},
child: Text(
"${AppLocalizations.of(context)!.replacePoints} +",
style: TextStyle(color: Colors.white),
))
Upvotes: 7