canLoadFont static method

Future<bool> canLoadFont(
  1. String url
)

Checks whether the given url can be loaded directly from cache.

  • REQUIRED The url property is used to specify the url for the required font. It should be a valid http/https url which points to a font file. The url should match the url passed to cacheFont.

Implementation

static Future<bool> canLoadFont(String url) async {
  WidgetsFlutterBinding.ensureInitialized();

  final String cacheKey = Utils.sanitizeUrl(url);

  final FileInfo? font =
      await DynamicCachedFontsCacheManager.getCacheManager(cacheKey)
          .getFileFromCache(cacheKey);

  return font != null;
}