isPort function

bool isPort(
  1. String str
)

Returns true if str is a valid network port number (1–65535).

Implementation

bool isPort(String str) {
  final port = int.tryParse(str);
  return port != null && port >= 1 && port <= 65535;
}