Reputation: 327
I wanna show the svg in a container
, the container colours does show as grey
but the vector image does not appear. No errors are being produced. I have added the dependancy flutter_svg: ^0.22.0
and
Svg image: this is placed at /Assets/Vector.svg
<svg width="25" height="26" viewBox="0 0 25 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.9435 8.38116H0.706215C0.282486 8.38116 0 8.62978 0 9.00271V25.1629C0 25.5359 0.282486 25.7845 0.706215 25.7845H4.9435C5.36723 25.7845 5.64972 25.5359 5.64972 25.1629V9.00271C5.64972 8.62978 5.36723 8.38116 4.9435 8.38116Z" fill="white"/> </svg>
Code:
import 'package:flutter_svg/flutter_svg.dart';
Container(
width: 200,
height: 200,
color: Colors.grey,
child: SvgPicture.asset('/Assets/Vector.svg',
color: Colors.black))
the small black line is the svg (appears in my browser)
Upvotes: 3
Views: 8095
Reputation: 837
try running flutter clean
and flutter pub get
, sometime cache causes crazy stuff
Upvotes: 0
Reputation: 94
What's the file path in your .yaml file? Is it /Assets/Vector.svg ? Because normally if you have only assets folder & no more sub-folder inside.
You should use the path 'Assets/Vector.svg' in your case.
In this case, my path is
child: SvgPicture.asset('assets/login.svg')
Upvotes: 3
Reputation: 471
Try to build the app all over again. Flutter clean to be precise. Some packeges requires a full rebuild including flutter_svg.
Upvotes: 2