loadAllFromPattern method

Future<List<Image>> loadAllFromPattern(
  1. Pattern pattern, {
  2. required String directory,
})

Loads all images under directory that match the specified pattern.

Images are cached under their full path, as listed in the asset manifest.

Implementation

Future<List<Image>> loadAllFromPattern(
  Pattern pattern, {
  required String directory,
}) async {
  assert(
    directory.isEmpty || directory.endsWith('/'),
    'directory must be empty or end with a "/"',
  );
  final manifest = await AssetManifest.loadFromAssetBundle(bundle);
  final imagePaths = manifest.listAssets().where((path) {
    return path.startsWith(directory) && path.toLowerCase().contains(pattern);
  });
  return loadAll(imagePaths.toList());
}