getOrFetchFontModels method
Gets all SDKPublishFont models of a given set of fontIDs
either from
local cache or downloads them from the network.
Implementation
Future<Set<SDKPublishFont>> getOrFetchFontModels({
required Set<String> fontIDs,
}) async {
final AuthData? auth = authManager.authData;
final Set<SDKPublishFont> fonts = {};
for (final String fontID in fontIDs) {
final SDKPublishFont? font = _publishModel?.fonts[fontID];
if (font != null) {
fonts.add(font);
} else {
if (auth == null) continue;
try {
final SDKPublishFont? downloadedFont =
await networkDataRepository.downloadFontModel(
projectID: auth.projectId,
fontID: fontID,
source: config.publishSource,
);
if (downloadedFont != null) {
fonts.add(downloadedFont);
}
} catch (e) {
log('\t\tFont [$fontID] could not be downloaded.');
}
}
}
return fonts;
}