My Issue: Aligning Text
with Container
/ Icon
in Row
Current Output: (I want to align this blue line with text horizontally center)
Expected Output: (Red horizontal line for a guideline)
My current code:
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Unit Details',
style: textTheme.bodyLarge,
),
kHorizontalSpaceS,
Container(
height: 4,
width: 42,
decoration: BoxDecoration(
color: Pallete.brandColor,
borderRadius: BorderRadius.circular(16),
),
),
],
),
I have less knowledge about Text
baseline, but I tried with CrossAxisAlignment.baseline
but it’s not working.
How can I horizontally align this blue Container
with the text?
I faced a similar issue with aligning Icon
and Text
in Row
.
2
Answers
Can you wrap your code with Container and give needful height.
I think you should use mainAxisAlignment since it is a row.