close method Null safety

Future<void> close()

Implementation

Future<void> close() async {
	if (clientsQueriesTimer != null) {
		clientsQueriesTimer!.cancel();
		clientsQueriesTimer = null;
	}
	final List<Future<void>> promises = <Future<void>>[];
	for (int i = clients.length - 1; i >= 0; i--) {
		promises.add(clients[i].close());
	}
	await Future.wait(promises);
	clients.clear();
	if (_httpServer != null) await _httpServer?.close();
	else if (_tcpServer != null) await _tcpServer?.close();
}