Changing Background Color Of Image in Flutter

前端 未结 5 2036
陌清茗
陌清茗 2021-01-15 03:10

Can we Change the background color on an Image in Flutter? Like in this Image I want to change the pink color background color to something else.

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 04:10

    I was also trying to add color to a background for a Transparent PNG

    This can be done by using a stack widget as below follows:

    Stack(
       children: [
         Container(
           width: double.infinity,
           height: double.infinity,
           margin: EdgeInsets.all(50),
           color: Colors.blue[500],
         ),
         Image.asset(
           'images/frame.png',
            fit: BoxFit.fill,
         ),
       ],
     )
    

    I added a margin so the colored background was only seen inside my photo frame image.

提交回复
热议问题