Flutter Svg image dosen't load

Viewed 4792

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,
        ); 
      },    
    ),
  )
);

} }

3 Answers

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

Add

assets:
    - assets/icons/

Edit

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

enter image description here

if have svg have style tag then not support flutter svg

this is working fine for me please see format in picture hope fully help you enter image description here

Related