getOrFetchFontBytesAndSave method

Future<Uint8List?> getOrFetchFontBytesAndSave(
  1. SDKPublishFont font
)

Given a font, will fetch its bytes either from cache or download & save them.

Implementation

Future<Uint8List?> getOrFetchFontBytesAndSave(SDKPublishFont font) async {
  log('\t\tChecking bytes for [${font.id}](${font.fullFontName}).');
  final Uint8List? fontBytes = localDataRepository.fetchFontBytes(
    fontID: font.id,
    source: config.publishSource,
  );
  if (fontBytes != null) {
    log('\t\tFont [${font.id}] bytes already cached.');
    return Future.value(fontBytes);
  } else {
    log('\t\tFont [${font.id}] bytes not cached. Downloading...');
    return downloadFontBytesAndSave(font);
  }
}