how to change size of svg image in flutter?

Issue

I used flutter_svg: ^0.18.0 to use svg images inside my project. But I cannot able to find a proper way to change the size of it.

Here’s my code

body: SafeArea(
    child: Center(
      child: SvgPicture.asset('assets/images/morelights.svg'),
    ),
  ),

Solution

I found a solution for this 🙂

Steps

  1. Wrap svg icon inside a container. ( Container should be a child widget)
  2. Set color of the container to transparent.
  3. Change the size of the container. (Svg icon inhert the size of parent widget.)

Note: You can use IconButton widget as well. Container works better in my case 🙂

Example

dart code

output

Answered By – Lojith Vinsuka Abeysinghe

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.