Reputation:
I've tried so many things and I can't get my image and text (column) to center inside of my Container. It stays at the top of the container. Here's my setup:
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
//Container 1
Container(
height: 150,
width: 150,
decoration: BoxDecoration(
color: Colors.green,
border: Border.all(color: Colors.green, width: 3),
borderRadius: BorderRadius.all(Radius.circular(18)),
),
child: Column(
children: const [
Expanded(
child: Image(
image: AssetImage('assets/images/Church.png'),
),
),
Expanded(
child: Text(
'Our Church',
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontFamily: 'DMSans',
fontWeight: FontWeight.w500,
),
),
),
],
)),
And here is the resulting image on screen:
Upvotes: 0
Views: 435
Reputation: 578
First Remove both Expanded
widget and then apply MainAxisAlignment
to center
.
Your code should look like this:
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
height: 150,
width: 150,
decoration: BoxDecoration(
color: Colors.green,
border: Border.all(color: Colors.green, width: 3),
borderRadius: const BorderRadius.all(Radius.circular(18)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Image.asset(
'assets/Avatar.png',
width: 60,
height: 40,
),
Text(
'Our Church',
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontFamily: 'DMSans',
fontWeight: FontWeight.w500,
),
),
],
),
),
],
);
}
Edit: I don't have Church image, Sorry for replacement.
Upvotes: 0