Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to center image on the flutter

Tags:

flutter

dart

Hello, I'm trying to center my images in the app, but I'm not getting it. What am I doing wrong? How am I going to centralize these images?


InkWell(
    child: new Padding(
      padding: EdgeInsets.only(top: 50),
      child: snapshot.data.Facebook != ""
          ? Row(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Align(
                  alignment: Alignment.bottomCenter,
                  child: Image.asset(
                    "assets/images/facebook.png",
                    height: 30,
                  ),
                ),
              ],
            )
          : Row(
              children: <Widget>[],
            ),
    ),
    onTap: () async {
      if (await canLaunch(snapshot.data.Facebook)) {
        await launch(snapshot.data.Facebook);
      } else {
        throw 'erro ao tentar acessar o facebook do(a) $snapshot.data.Nome';
      }
    }),

I'm stopped at this

enter image description here

like image 489
Thiago Correa Avatar asked Nov 23 '25 14:11

Thiago Correa


1 Answers

Use mainAxisAlignment to align their child to center, spaceAround, spaceBetween, etc .

and mainAxisSize to provide size of mainAxis .

 InkWell(  
    child: new Padding(  
     padding: EdgeInsets.only(top: 50),  
      child: snapshot.data.Facebook != ""          
      ?      
        Row(
          mainAxisAlignment : MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            Align(
              alignment: Alignment.bottomCenter,
              child: Image.asset(
                "assets/images/facebook.png",
                height: 30,
              ),
            ),
          ],
        )
      : Row(
          children: <Widget>[],
        ),
),
onTap: () async {
  if (await canLaunch(snapshot.data.Facebook)) {
    await launch(snapshot.data.Facebook);
  } else {
    throw 'erro ao tentar acessar o facebook do(a) $snapshot.data.Nome';
  }
}),
like image 105
Sonu Saini Avatar answered Nov 25 '25 09:11

Sonu Saini