DEV Community

Neto Ukpong
Neto Ukpong

Posted on

3 2

How to Render an SVG Image in Flutter

By default, Flutter does not support SVG images.
You would need an external package to render the images.

In comes flutter_svg to the rescue.

Here's a link to the pub.dev page.

Adding the plugin

To add the package, run:
flutter pub add flutter_svg
This adds the package to your pubspec.yaml file. Afterwards, you will need to install it, run:
flutter pub get

Using flutter_svg in your app

import:'package:flutter_svg/flutter_svg.dart'

@override
Widget build(BuildContext context) {
 return SafeArea(
    child: Center(
      child: SvgPicture.asset('assets/image.svg')
    ),
  );
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay