Reputation: 231
Hi I cant seem to figure out how do I correct the alignment of the icon button that I have placed and remove the unnecessary space
what I want to achieve:
What I am getting:
Here is my code:
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
style: TextStyle(
color: AppColor.primarypurple,
fontSize: 14,
fontWeight: FontWeight.w500,
),
children: [
TextSpan(text: widget.heading
),
WidgetSpan(child:IconButton(icon:Icon(Icons.info),color:AppColor.darkBlue , onPressed: ()=>showDialog(context: context, builder: (context)=> alert),) )
]
),
),
Upvotes: 0
Views: 139
Reputation: 458
Instead, you should display just the Icon widget wrapped with Inkwell like so:
InkWell(
child: Icon(Icons.info, color:AppColor.darkBlue),
onTap: ()=>showDialog(context: context, builder: (context)=> alert),) )
)
Or Wrap the IconButton inside a Container which has a width.
For example:
Container(
padding: const EdgeInsets.all(0.0),
width: 30.0, // you can adjust the width as you need
child: IconButton(
),
),
Display with a Text Widget before the icon like so
Row(
children: [
Text('Your text'),
Spacer(),
InkWell(
child: Icon(Icons.info, color:AppColor.darkBlue),
onTap: ()=>showDialog(
context: context,
builder: (context)=> alert),
),
),
],
)
Upvotes: 2