Changing Background Color Of Image in Flutter

前端 未结 5 2037
陌清茗
陌清茗 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 03:56

    I have come up with this solution. So, you can contain the widget and then decorate the container with a color.

    Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(8),
                  color: Colors.black,
                ),
                child: ClipRRect(
                    borderRadius: BorderRadius.circular(8),
                    child: Image(
                      image: AssetImage(imageLink),
                    ),
                  
                ),
              ),
    

    You don't need the borderRadius but in my case I used ClipRRect with borderRadius.

提交回复
热议问题