chore: Implement svg pre-caching

This commit is contained in:
PartyDonut 2025-10-16 23:03:09 +02:00
parent 91c548c412
commit 2ce13cbd09
2 changed files with 25 additions and 0 deletions

22
lib/util/svg_utils.dart Normal file
View file

@ -0,0 +1,22 @@
import 'package:flutter_svg/flutter_svg.dart';
class SvgUtils {
static List<String> allSvgs = [
'icons/fladder_icon.svg',
'icons/fladder_icon_outline.svg',
];
static Future<void> preCacheSVGs() async {
try {
for (final path in allSvgs) {
final loadSvg = SvgAssetLoader(path);
await svg.cache.putIfAbsent(
loadSvg.cacheKey(null),
() => loadSvg.loadBytes(null),
);
}
} catch (e) {
print(e);
}
}
}