I want to add padding to the icons on the AppBar.
I tried wrapping icons with Padding() but that only squeezes them to the allocated space–not the one I give it.
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.only(left: 10),
child: const Icon(
image: Icon(""),
width: 50,
height: 50,
),
);
}
My app bar currently looks like this
With the code:
Widget build(BuildContext context) {
return AppBar(
leading: RedBlock(),
actions: [YellowBlock()],
backgroundColor: Theme.of(context).primaryColor,
);
}
}
I want to push the two icons a little to the center like so:
Whats the best to way to accomplish this?
2
Answers
You can implement the
PreferredSizeWidget
to create custom appBar.Now you can use
MyAppBar
in placeappBar:MyAppBar()
.you can wrap the icons with a
Padding
widget and adjust thepadding
values accordingly. Additionally, you can use the Row widget to align theleading
and action iconshorizontally
.You can adjust the padding values as needed to achieve the desired spacing.