isPortAvailable function
Check if a port is available
Implementation
Future<bool> isPortAvailable(int port) async {
try {
final server = await ServerSocket.bind('0.0.0.0', port);
await server.close();
return true;
} catch (e) {
return false;
}
}