waitForNetworkImages method

Future<void> waitForNetworkImages()

Tries to preload all NetworkImages in the current widget tree.

Implementation

Future<void> waitForNetworkImages() async {
  if (kIsWeb) {
    return;
  }

  await runAsync(() async {
    var futures = <Future>[];
    for (final image in _listImages()) {
      if (image.provider is NetworkImage) {
        futures.add(precacheImage(image.provider, image.context));
      }
    }
    await Future.wait(futures);
  });
}