Home > Enterprise >  How to set margin for children
How to set margin for children

Time:06-22

Iam new to flutter and i want to set top margin for Image in the below code, how i can do that? Just designing a screen with text and image on the screen.

Here is my code:

Widget build(BuildContext context) {

SizeConfig().init(context);

return Container(
    padding: new EdgeInsets.only(top: 160,left: SizeConfig.blockSizeHorizontal*5,right: SizeConfig.blockSizeHorizontal*5),

    decoration: BoxDecoration(
        image: DecorationImage(
            image: new AssetImage("images/bg_splash.png"),
            fit: BoxFit.fill)
    ),

    child: Column(
      children: [
        Text(
          "App is allowing users to learn & Grow their Brains",
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      decoration: TextDecoration.none,
                      fontSize: 25.0,
                      color: Color(0xFFFDEA20),
                      fontFamily: "Calistoga",
                    ),

        ),
        Image(
          image: AssetImage('images/logo.png'),
          height: 175,

        ),
      ],
    ));

}

CodePudding user response:

Add SizedBox(height: 10.0), with your requirement in column above Image() widget

return Container(
    padding: new EdgeInsets.only(
        top: 160,
        left: SizeConfig.blockSizeHorizontal * 5,
        right: SizeConfig.blockSizeHorizontal * 5),
    decoration: BoxDecoration(
        image:
            DecorationImage(image: new AssetImage("images/bg_splash.png"), fit: BoxFit.fill)),
    child: Column(
      children: [
        Text(
          "App is allowing users to learn & Grow their Brains",
          textAlign: TextAlign.center,
          style: TextStyle(
            decoration: TextDecoration.none,
            fontSize: 25.0,
            color: Color(0xFFFDEA20),
            fontFamily: "Calistoga",
          ),
        ),
        SizedBox(height: 10.0),
        Image(
          image: AssetImage('images/logo.png'),
          height: 175,
        ),
      ],
    ));

CodePudding user response:

wrap your image widget with padding

          Padding(
              padding: const EdgeInsets.only(top:10),
              child: Image(
                image: AssetImage('images/logo.png'),
                height: 175,

              ),
            ),
  • Related