isPort function

bool isPort(
  1. String str
)

Checks if the string is a valid port number.

A valid port is an integer in the range 0–65535 without leading zeros.

Example:

isPort('8080'); // true
isPort('0'); // true
isPort('65536'); // false (out of range)
isPort('080'); // false (leading zero)

Implementation

bool isPort(String str) => _isPort(str);