CODEforDREAM
CODEforDREAM

Reputation: 1093

SVG image overflows from the container

I just learn flutter, but i have trouble when deal with images, here is a SVG images, it not fit into container, no matter how i use fit: Boxfit , please help, thank a lots.

here is the code of Container

Column(
                    children: [
                      InkWell(
                        onTap: (){
                          print("heeloo");
                        },
                        child: Container(
                          decoration: BoxDecoration(
                            shape: BoxShape.circle,
                            border: Border.all(width: 1.5)
                          ),
                          height: SizeConfig.screenHeight * 0.12,
                          width: SizeConfig.screenHeight * 0.12,
                          child: SvgPicture.asset(
                            newChat,
                            //fit: B,
                            height: SizeConfig.screenHeight * 0.1,
                            width: SizeConfig.screenHeight * 0.1,
                          ),
                        ),
                      ),
                      SizedBox(height: 10,),
                      Text(
                        "New Chat",
                        style: TextStyle(
                          fontFamily: fontBold,
                          fontSize: 25,
                        ),
                      )
                    ],
                  ),

Here is result

pic

but i want something like this

pic

Upvotes: 0

Views: 2358

Answers (2)

Aman Verma
Aman Verma

Reputation: 918

Adding the padding padding: EdgeInsets.all(5), to the container works like charm.

Upvotes: 1

AL.Sharie
AL.Sharie

Reputation: 1615

add some padding in the container padding: EdgeInsets.all(10)


 Container(
                decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    border: Border.all(width: 1.5)
                ),
                padding: EdgeInsets.all(10),
                height: MediaQuery.of(context).size.height * 0.12,
                width: MediaQuery.of(context).size.height * 0.12,
                child: SvgPicture.asset(
                  "assets/WQb.svg",
                  //fit: B,
                  height: MediaQuery.of(context).size.height * 0.1,
                  width: MediaQuery.of(context).size.height * 0.1,
                ),
              ),
            ),

enter image description here

Upvotes: 4

Related Questions