faviconProvider top-level property

FutureProviderFamily<String?, String> faviconProvider
final

Provider for getting the best favicon.

Implementation

final faviconProvider =
    FutureProvider.family<String?, String>((ref, url) async {
  String? cachedFaviconUrl =
      ReaderBrowserSource.instance.getCachedFaviconUrl(url);
  if (cachedFaviconUrl != null) {
    return cachedFaviconUrl;
  }

  Favicon? favicon = await FaviconFinder.getBest(url);
  favicon ??= await FaviconFinder.getBest(Uri.parse(url).host);

  if (favicon != null) {
    ReaderBrowserSource.instance.setCachedFaviconUrl(url, favicon.url);
  }

  return favicon?.url;
});