cacheFontStream static method

Stream<FileInfo> cacheFontStream(
  1. String url, {
  2. Duration cacheStalePeriod = kDefaultCacheStalePeriod,
  3. int maxCacheObjects = kDefaultMaxCacheObjects,
  4. DownloadProgressListener? progressListener,
})

Downloads and caches font from the url with the given configuration. A single FileInfo object is returned as a stream and the download progress is can be listened to using the progressListener callback.

If this method is called multiple times for the same font url, then the cached file is returned with no progress events being emitted to the progressListener callback.

  • REQUIRED The url property is used to specify the download url for the required font. It should be a valid http/https url which points to a font file. Currently, only OpenType (OTF) and TrueType (TTF) fonts are supported.

  • The maxCacheObjects property defines how large the cache is allowed to be. If there are more files the files that haven't been used for the longest time will be removed.

    It is used to specify the cache configuration, Config, for CacheManager.

  • cacheStalePeriod is the time duration in which a cache object is considered 'stale'. When a file is cached but not being used for a certain time the file will be deleted

    It is used to specify the cache configuration, Config, for CacheManager.

  • The progressListener property is used to listen to the download progress of the font. It is called with a DownloadProgress object which contains information about the download progress.

Implementation

static Stream<FileInfo> cacheFontStream(
  String url, {
  Duration cacheStalePeriod = kDefaultCacheStalePeriod,
  int maxCacheObjects = kDefaultMaxCacheObjects,
  DownloadProgressListener? progressListener,
}) =>
    RawDynamicCachedFonts.cacheFontStream(
      url,
      cacheStalePeriod: cacheStalePeriod,
      maxCacheObjects: maxCacheObjects,
      progressListener: progressListener,
    );