precacheIcons static method
Renders the custom icons of items ahead of the bar's first mount.
Pass the same items and iconSize as the bar, so it skips its
Flutter fallback on mount.
Implementation
static Future<void> precacheIcons(
List<CNTabBarItem> items, {
double? iconSize,
}) async {
final renders = <Future<Uint8List?>>[];
for (final item in items) {
if (item.imageAsset == null && item.customIcon != null) {
renders.add(
iconDataToImageBytes(
item.customIcon!,
size: _customIconSize(item, iconSize),
),
);
}
if (item.activeImageAsset == null && item.activeCustomIcon != null) {
renders.add(
iconDataToImageBytes(
item.activeCustomIcon!,
size: _activeCustomIconSize(item, iconSize),
),
);
}
}
await Future.wait(renders);
}