这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@stijn1989
Copy link
Contributor

When an active connection to the MQTT server is lost. The _disconnect() method sets the authenticationManager to null.
When you call connect() again on the client, you get an exception "Null check operator used on a null value".
With this extra line of code, the authenticationManager has an object for sure.

Class MQTT {
  ....
  
  Future<MqttConnectionStatus?> connect() async {
    return client.connect(user, pass);
  }
  
  ...
}
...
FloatingActionButton(
  child: Icon(Icons.message),
  onPressed: () async {
      await mqtt.connect(); //<- here you get the exception when pressing the button when the MQTT is back online.
      mqtt.sub();
  }
)
....

When an active connection to the MQTT server is lost. The _disconnect() method sets the authenticationManager to null. 
When you call connect() again on the client, you get an exception "Null check operator used on a null value". 
With this extra line of code, the authenticationManager has an object for sure.
@shamblett shamblett merged commit 7d80ba0 into shamblett:master Oct 7, 2021
@shamblett
Copy link
Owner

Yes good catch, client updated and re published at version 3.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants