subscribe method Null safety

Subscription? subscribe(
  1. String topic,
  2. MqttQos qosLevel

Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The topic to subscribe to. The qos level the message was published at. Returns the subscription or null on failure


Subscription? subscribe(String topic, MqttQos qosLevel) {
  if (connectionStatus!.state != MqttConnectionState.connected) {
    throw ConnectionException(connectionHandler?.connectionStatus?.state);
  return subscriptionsManager!.registerSubscription(topic, qosLevel);