dbPort property

FutureOr<int> get dbPort

The dbConfig port (database exposed port for connections).

Implementation

FutureOr<int> get dbPort {
  var port = dbConfig['port'];

  if (port is String) {
    port = int.tryParse(port.trim()) ?? 0;
  }

  if (port is int) {
    if (port > 0) return port;

    if (port > -1000) {
      port = 5000;
    } else {
      port = -port;
    }

    return resolveFreePort(port).then((p) {
      dbConfig['port'] = p;
      return p;
    });
  } else if (port == null || port == '?' || port == '*') {
    return resolveFreePort(5000).then((p) {
      dbConfig['port'] = p;
      return p;
    });
  }

  throw StateError("Can't resolve `dbPort`: $port");
}