Home > Net >  Want to add a child property to the Image.asset widget in flutter
Want to add a child property to the Image.asset widget in flutter

Time:07-28

I want to add a child widget in my Image.asset widget so that I can wrap partially overlap the image.

   Container(
          height: 70.h,
          width: 100.h,
          color: Colors.white,
          child: Padding(
            padding: EdgeInsets.fromLTRB(3.h, 2.h, 3.h, 0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('Handpicked Projects',
                style: TextStyle(
                  fontSize: 17.sp,
                ),),
                SizedBox(
                  height: 2.h,
                ),
                Image.asset('assets/Rectangle142.png',
                fit: BoxFit.cover,

                ),
                
              ],
            ),
          ),
        ),

CodePudding user response:

You should take a look at this Widget called

Stack Widget

CodePudding user response:

You can use Stack widget.

Stack(
  children: [
    //background
    Image.asset(
      'assets/Rectangle142.png',
      fit: BoxFit.cover,
    ),
    // top widget
  ],
),

If you needed sizing, wrap stack widget with SizedBox

CodePudding user response:

Since you don't wish to use a stack you can use this.. A container widget has a decoration.. You can use that to add an image as a background decoration

Container(
  decoration: BoxDecoration(
   image: DecorationImage(
    image:AssetImage(
     'assets/Rectangle142.png',
    )
   )
 ),
 child: Column(
   children: []
 )
)
  • Related