getTableScheme method

FutureOr<TableScheme?> getTableScheme(
  1. String table, {
  2. TableRelationshipReference? relationship,
  3. Object? contextID,
})

Returns a TableScheme for table. Calls getTableSchemeImpl handling asynchronous calls.

  • contextID should be Expando compatible. It informs that other calls to getTableScheme are in the same context and could have shared internal caches for the same contextID instance.

Implementation

FutureOr<TableScheme?> getTableScheme(String table,
    {TableRelationshipReference? relationship, Object? contextID}) {
  var tablesScheme = _tablesSchemes[table];
  if (tablesScheme != null) return tablesScheme;

  var resolving = _tablesSchemesResolving[table];
  if (resolving != null) {
    return resolving.future;
  }

  var completer = Completer<TableScheme?>();
  _tablesSchemesResolving[table] = completer;

  var ret = getTableSchemeImpl(table, relationship, contextID: contextID);

  return ret.resolveMapped((tablesScheme) {
    if (tablesScheme != null) {
      _tablesSchemes[table] = tablesScheme;
    }

    completer.complete(tablesScheme);
    _tablesSchemesResolving.remove(table);

    return tablesScheme;
  });
}