custom static method
Accepts cacheManager
and force
to provide a custom CacheManager for testing.
-
REQUIRED The
cacheManager
property is used to specify a custom instance of CacheManager. Caching can be customized using the Config object passed to the instance. -
The
force
property is used to specify whether or not to overwrite an existing instance of custom cache manager.If
force
is true and a custom cache manager already exists, it will be overwritten with the new instance. This means any fonts cached earlier, cannot be accessed using the new instance.
Any new DynamicCachedFonts instance or any RawDynamicCachedFonts methods
called after this method will use cacheManager
to download, cache
and load fonts. This means custom configuration cannot be provided.
maxCacheObjects
and cacheStalePeriod
in cacheFont will have no effect
after calling this method. Customize these values in the Config object
passed to the CacheManager used in cacheManager
.
Implementation
@visibleForTesting
static void custom({
required CacheManager cacheManager,
bool force = false,
}) {
if (force)
DynamicCachedFontsCacheManager.setCustomCacheManager(cacheManager);
else if (DynamicCachedFontsCacheManager.getCustomCacheManager() == null)
DynamicCachedFontsCacheManager.setCustomCacheManager(cacheManager);
}