downloadSvgaAndSave static method
Implementation
static Future<Uint8List?> downloadSvgaAndSave(String? url) async {
if (url == null) {
return null;
}
Directory documentDirectory = await getTemporaryDirectory();
Directory directory = new Directory('${documentDirectory.path}/svga');
if (!directory.existsSync()) {
directory.createSync();
}
bool isDownload = false;
String svgaName = url.split('/').last;
directory.listSync().forEach((element) {
if (svgaName == element.path.split('/').last) {
isDownload = true;
}
});
if (!isDownload) {
await Dio().download(
url,
directory.path + '/' + svgaName,
onReceiveProgress: (count, total) {},
);
}
Uint8List uint8list =
File(directory.path + '/' + svgaName).readAsBytesSync();
return uint8list;
}