how to remove border in OutlinedButton - flutter

I'm having trouble when I want to remove the border on the OutlineButton
OutlinedButton(
onPressed: () {},
child: const Text('Pext Page'),
)
please help me!!

Try below code hope its help to you.
OutlinedButton(
onPressed: () {},
child: Text('Outlined button'),
style: OutlinedButton.styleFrom(
side: BorderSide(
color: Colors.transparent,
),
),
),
Your result screen->
Or you can used TextButton also
TextButton(
onPressed: () {},
child: Text('Text button'),
),
Your result screen using TextButton->

Related

Is possible to edit AppBar icon background?

I'm trying to change the background color only of the icon that is on the leading of the native AppBar of flutter, but I don't know how, does anyone know if it's possible?
If you are using flutter 3.3, you could do like:
Material(
color: Colors.redAccent,
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.search),
),
),
This apparently solves my initial problem
leading: IconButton(
onPressed: () {...},
icon: Container(
color: Colors.white,
child: const Icon(
Icons.arrow_back,
color: Colors.black,
),
),
),

Custom Textbutton shape

How to achieve Textbutton shape like this image
I've tried this
TextButton(
onPressed: () {},
style: ButtonStyle(
shape: MaterialStateProperty.all<BeveledRectangleBorder>(
BeveledRectangleBorder(
borderRadius: BorderRadius.circular(10),
)),
backgroundColor: MaterialStateProperty.all<Color>(Colors.red),
),
child: Text('')),
Use this package make some changes and wrap with InkWell https://pub.dev/packages/shape_of_view_null_safe

How to change color in TextButton.icon

I want to have an icon with text, so I used TextButton.icon but I can not change the color of the text or icon!
Please suggest if anyone has a solution
this is my code:
SizedBox(height: 8,),
TextButton.icon(
icon: Icon(Icons.delete),
label: Text('delete'),
onPressed: (){},
),
You can use the TextButton.stylefrom on the style of the TextButton. In this method, you can use primary to set the colors of both the icon and label. If you want to set another color for the icon, you can set the icon color in Icon.
TextButton.icon(
onPressed:(){}),
style: TextButton.styleFrom(
primary: Colors.blue,
),
icon: Icon(Icons.ac_unit, color: Colors.red),
label: Text("label"),
)
Building on Emmanuel Ashitey's answer, the "primary" method has been deprecated as of v3.1.0 (per VSCode tooltips) and should be replaced with "foregroundColor":
TextButton.icon(
onPressed: () {},
icon: const Icon(Icons.delete),
label: const Text('Delete'),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).errorColor,
),
),
Obviously Theme.of(context).errorColor can be replaced with Colors.red for this scenario.
Try below code hope its helpful to you.
Refer TextButton here
TextButton.icon(
icon: Icon(
Icons.delete,
color: Colors.red,//for icon color
),
label: Text(
'Delete',
style: TextStyle(
color: Colors.red,//for text color
),
),
onPressed: () {},
),
Result Screen->

I'm getting a strange error when using "color:"

I get this error when using color:
The named parameter 'color' isn't defined.
code is:
body: Center(
child: ElevatedButton(
child: Text('click'),
onPressed: () {} ,
color: Colors.green[300],
),
),
Type style then next is this
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.green[300],
),
onPressed: () {},
child: Text("click"),
),

CircleAvatar with IconButton not centered

I want to center the button in the CircleAvatar, but for smaller radius, it doesn't seem to be centering correctly.
CircleAvatar(
backgroundColor: Colors.blue,
radius: 16,
child: IconButton(
icon: Icon(Icons.add),
color: Colors.white,
onPressed: () {
}
}),
),
This is what it looks like:
The IconButton has some default padding, fix the issue by removing the default padding.
Check the code below, it works perfectly.
CircleAvatar(
backgroundColor: Colors.blue,
radius: 16,
child: IconButton(
// remove default padding here
padding: EdgeInsets.zero,
icon: Icon(Icons.add),
color: Colors.white,
onPressed: () {},
),
),
Output of the code:
You can use floatingActionButton to achieve that
Container(
child: floatingActionButton(
child: Icon(Icons.add),
),
),
Hope it helps..!
CircleAvatar generally we used for displaying image, we can have some better option like material button
MaterialButton(
onPressed: () {},
color: Colors.blue,
textColor: Colors.white,
child: Icon(
Icons.add,
size: 16,
),
shape: CircleBorder(),
)
Output: