query<T extends PackMeMessage> method Null safety

Future<T> query<T extends PackMeMessage>(
  1. PackMeMessage message
)

Implementation

Future<T> query<T extends PackMeMessage>(PackMeMessage message) {
	final Completer<T> completer = Completer<T>();
	final Uint8List? data = _packMe.pack(message);
	if (data != null && socket.state == WebSocket.open) {
		_queries[message.$transactionId] = _Query<T>(completer);
		socket.add(data);
	}
	else {
		onError?.call("ConnectMe client.query() failed to pack message, future won't be resolved");
	}
	return completer.future;
}