Search code examples
flutterdart

How to resize on asset level with data format png using Flutter?


I am making an App using Flutter, but the asset image does not fit well into the FrontEnd, was wondering how to resize it on asset level, maybe using ClipRect code: Image.asset("assets/stars_icon.png", width: 50, height: 50,),

I tried using width, and height property of the asset but it scales the asset instead resizing it


Solution

  • The best solution i have found that works for me is :

    Container(
                height: 50,
                width: 50,
                decoration: const BoxDecoration(
                  shape: BoxShape.circle,
                  image: DecorationImage(
                    fit: BoxFit.contain,
                      image: AssetImage(
                        'assets/images/other/logo.png',
                      )
                  )
                ),
              ),
    

    Other alternatives you can use are : CircleAvatar, ClipRRect.