Flutter Svg image dosen't load

When I run my code the svg does not appear. I already added flutter_svg: ^0.19.0 to the dependencies.

How can i solve this?

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class HomeScreen extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        leading: Builder(
          builder: (BuildContext context) {
            return IconButton(
              icon: SvgPicture.asset('assets/icons/home.svg'),
              onPressed: () { Scaffold.of(context).openDrawer(); },
               tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,

} }

1 answer

  • answered 2020-09-24 15:02 jitsm555

    Looks like the asset path is missing in pubspec.yaml file


        - assets/icons/


    and please check your svg file ... Flutter_svg only support special svg format .you should Export your svg like this.

    enter image description here