Reputation: 99
i am trying to align the image in center of the screen but it not working , can someone help me understand whats wrong with the code? and why the alignment: Alignment.center,
isnt working ?
Please have a look at the image i attached below , the logo is painted towards the left of the screen and not in the center
Row(
children: <Widget>[
Container(
alignment: Alignment.center,
child:Container(
child: Image.asset('assets/logo.png'),
height: 200.0,
),
),
],
),
Upvotes: 0
Views: 1517
Reputation: 7105
Yes, Marcel Dz is suggesting correct add mainAxisAlignment:MainAxisAlignment.center,
for row to show image in center
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
alignment: Alignment.center,
child: Container(
child: Image.asset('assets/images/logo.png'),
height: 200.0,
),
),
],
),
Upvotes: 2
Reputation: 2714
You can remove the alignment
from your Container()
and manage it with your parent widget Row()
by using MainAxisAlignment.center
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
...
Upvotes: 4