getRepositoriesSchemes method

Future<Map<EntityRepository<Object>, TableScheme?>> getRepositoriesSchemes()

Implementation

Future<Map<EntityRepository<Object>, TableScheme?>>
    getRepositoriesSchemes() async {
  var reposBlocks =
      entityRepositories.splitBeforeIndexed((i, r) => i % 2 == 0).toList();

  final allSchemes = <EntityRepository<Object>, TableScheme?>{};

  // Call `getTableSchemeForEntityRepository` with a `contextID` to allow
  // shared internal cache between multiple calls:
  final contextID = List.unmodifiable([this, "getRepositoriesSchemes"]);

  for (var block in reposBlocks) {
    var repositorySchemes = await block
        .map((r) => MapEntry(
            r, getTableSchemeForEntityRepository(r, contextID: contextID)))
        .toMapFromEntries()
        .resolveAllValues();

    allSchemes.addAll(repositorySchemes);
  }

  return allSchemes;
}