loadCachedFamilyStream static method

Stream<FileInfo> loadCachedFamilyStream(
  1. List<String> urls, {
  2. required String fontFamily,
  3. ItemCountProgressListener? progressListener,
  4. @visibleForTesting FontLoader? fontLoader,
})

Fetches the given urls from cache and loads them into the engine to be used. A stream of FileInfo objects is returned, which emits the font files as they are loaded. The total number of files returned corresponds to the number of urls provided. The download progress can be listened to using progressListener.

urls should be a series of related font assets, each of which defines how to render a specific FontWeight and FontStyle within the family.

Call canLoadFont before calling this method to make sure the font is available in cache.

  • REQUIRED The urls property is used to specify the urls for the required family. It should be a list of valid http/https urls which point to font files. Every url in urls should be loaded into cache by calling cacheFont for each.

  • REQUIRED The fontFamily property is used to specify the name of the font family which is to be used as TextStyle.fontFamily.

  • The progressListener property is used to listen to the download progress of the font. It gives information about the number of files downloaded and the total number of files to be downloaded. It is called with

    a double value which indicates the fraction of items that have been downloaded, an int value which indicates the total number of items to be downloaded and, another int value which indicates the number of items that have been downloaded so far.

Implementation

static Stream<FileInfo> loadCachedFamilyStream(
  List<String> urls, {
  required String fontFamily,
  ItemCountProgressListener? progressListener,
  @visibleForTesting FontLoader? fontLoader,
}) =>
    RawDynamicCachedFonts.loadCachedFamilyStream(
      urls,
      fontFamily: fontFamily,
      progressListener: progressListener,
      fontLoader: fontLoader,
    );