I'm using flutter_svg package to render SVG images in my app, as flutter does not officially supports SVG yet.I'm having a delay of probably few seconds while trying to load SVG images in my app and while looking for the solution I found out that I can preload the SVG image using preCachePicture(). The problem is that the official flutter_svg documentation does not clearly states nor there are other web material to show how to use this function to preload SVG images.
I'm calling loadPictures()
function in initState()
to preload the SVG picture.
String onboardImage = 'assets/images/onboard.svg';
@override
void initState() {
loadPictures();
super.initState();
}
Future<void> loadPictures() async {
await precachePicture(ExactAssetPicture((SvgPicture.svgStringDecoder),onboardImage), null);
}
After calling
preCachePicture()
, How to load the precached image when I wanted to use it ?