How to display SVG image in flutter? | SVG Image From Asset and Network | flutter_svg: ^0.22.0

Published: 06 April 2023
on channel: True Coders
8,373
56

https://www.youtube.com/@truecoders?s...
‪@TrueCoders‬

Smaple SVG Link
https://dev.w3.org/SVG/tools/svgweb/s...
https://dev.w3.org/SVG/tools/svgweb/s...

how to display an svg image in flutter?

To display an SVG image in Flutter, you can use the flutter_svg package. Here are the steps:
1 Add the flutter_svg package to your pubspec.yaml file:

dependencies:
flutter_svg: ^0.22.0

2 Run flutter pub get to download the package.
3 Import the flutter_svg package in your Dart file:

import 'package:flutter_svg/flutter_svg.dart';

4 Use the SvgPicture.asset or SvgPicture.network constructor to display the SVG image:

SvgPicture.asset(
'assets/images/my_image.svg',
width: 200,
height: 200,
),


Or

SvgPicture.network(
'https://example.com/my_image.svg',
width: 200,
height: 200,
),


In the above examples, the width and height parameters specify the dimensions of the SVG image in the Flutter app. You can adjust these values to suit your needs.
Note: Make sure that the SVG image file is located in the assets folder (for SvgPicture.asset) or accessible from the internet (for SvgPicture.network).


Watch video How to display SVG image in flutter? | SVG Image From Asset and Network | flutter_svg: ^0.22.0 online, duration hours minute second in high quality that is uploaded to the channel True Coders 06 April 2023. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 8,373 times and liked it 56 visitors.