Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 301 Vote(s) - 3.64 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change OutlinedButton border color?

#1
Flutter widget, I tried to change the OutlineButton border color by using BorderSide(color : Colors.blue). The OutlineButton always with grey color border no matter which color is set, but width change is applicable. How to change the OutlineButton border line color?

class OutlineButtonWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Center(
child: OutlineButton(
onPressed: null,
borderSide: BorderSide(
width: 5.0,
color: Colors.blue,
style: BorderStyle.solid,
),
child: Text('outline button')
),
),
);
}
}

Reply

#2
Style property will work
```
OutlineButton(
onPressed: (){},
style: OutlinedButton.styleFrom(
side: BorderSide(
width: 5.0,
color: Colors.blue,
style: BorderStyle.solid,
),
),
child: Text('outline button')
),
),

```
Reply

#3
**use *style* property**



style: ButtonStyle(
side: MaterialStateProperty.all(BorderSide(
color: Colors.blue,
width: 1.0,
style: BorderStyle.solid)))


----------
**or try this both work**


style: OutlinedButton.styleFrom(
side: BorderSide(
width: 5.0,
color: Colors.blue,
style: BorderStyle.solid,
),
),
child: Text('outline button')
)

----------


OutlinedButton(
style: ButtonStyle(
side: MaterialStateProperty.all(BorderSide(
color: Colors.blue,
width: 1.0,
style: BorderStyle.solid))),
onPressed: () {},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 12.0),
child: Icon(
Icons.clear,
size: 24,
),
),
),
Text("Clear")
],
))



result may like this
[![enter image description here][1]][1]


[1]:
Reply

#4
Use the`style` property:

```dart
OutlinedButton(
onPressed: () {},
child: Text('Outlined button'),
style: OutlinedButton.styleFrom(
side: BorderSide(width: 5.0, color: Colors.blue),
),
)
```
Reply

#5
I was getting 'OutlineButton' is deprecated and shouldn't be used. Use OutlinedButton instead. See
the migration guide in flutter.dev/go/material-button-migration-guide).

Before migration code:

child: OutlineButton(
onPressed: onPressed,
child: CustomText(
text,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
color: Colors.black),
),
color: Colors.orange,
borderSide: BorderSide(color: Colors.amber),
),


After migration code:

child: OutlinedButton(
onPressed: onPressed,
child: CustomText(
text,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
color: Colors.black),
),
style: OutlinedButton.styleFrom(backgroundColor: Colors.orange, side: BorderSide(color: Colors.amber)),
),

Here is official ref of backgroundColor and color properties:

[To see links please register here]


[To see links please register here]

Reply

#6
## Theming
I wanted to avoid manually theming each `OutlinedButton`, and use theming instead.

You can do this with `ThemeData`'s `outlinedButtonTheme`:
```dart
final color = ...;
ThemeData(
...
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
side: MaterialStateProperty.all(const BorderSide(color: color)),
// surfaceTintColor: MaterialStateProperty.all(Colors.blue),
)),
);
```

[![Animation using Flutter hot reload to change border style][1]][1]


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through