\n","author":{"@type":"Person","name":"JayVDiyk"},"upvoteCount":0,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"
I made a demo of what you are trying to achieve:
\n return Scaffold(\n appBar: AppBar(\n backgroundColor: Colors.green,\n title: Text(\n 'Title',\n ),\n centerTitle: true,\n actions: [\n // squared button/icon\n Padding(\n padding: const EdgeInsets.only(right: 20.0, top: 10.0, bottom: 10.0),\n child: Container(\n width: 35,\n decoration: BoxDecoration(\n borderRadius: BorderRadius.circular(8.0),\n color: Colors.white.withOpacity(0.5),\n ),\n child: Center(\n child: Icon(\n Icons.settings,\n color: Colors.white,\n ),\n ),\n ),\n ),\n ],\n ),\n body: .... YOUR WIDGETS ...\n
\nRESULT:
\n\n","author":{"@type":"Person","name":"timilehinjegede"},"upvoteCount":3}}}Reputation: 4487
I am wondering how do we make an App Bar action button like the one in the picture. It seems that adding a background or wrapping a widget on an Icon will not achieve the look of the button in the picture below.
Upvotes: 0
Views: 2802
Reputation: 14053
I made a demo of what you are trying to achieve:
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title: Text(
'Title',
),
centerTitle: true,
actions: [
// squared button/icon
Padding(
padding: const EdgeInsets.only(right: 20.0, top: 10.0, bottom: 10.0),
child: Container(
width: 35,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: Colors.white.withOpacity(0.5),
),
child: Center(
child: Icon(
Icons.settings,
color: Colors.white,
),
),
),
),
],
),
body: .... YOUR WIDGETS ...
RESULT:
Upvotes: 3
Reputation: 703
You can use an Icon
inside a Container
with equal width
and heigth
(so you obtain a square), then you can round it with BorderRadius
to obtain that effect.
Of course you should use the color property of the Container to fill the background.
Upvotes: 0