onStatusChanged method

Future onStatusChanged({
  1. OnConnected? onConnectedResult,
  2. OnConnecting? onConnectingResult,
  3. OnDisconnected? onDisconnectedResult,
  4. OnError? onError,
})

As the status changed , it gets called

Implementation

Future onStatusChanged({
  OnConnected? onConnectedResult,
  OnConnecting? onConnectingResult,
  OnDisconnected? onDisconnectedResult,
  OnError? onError,
}) async {
  Future methodCallReceiver(MethodCall call) async {
    var arg = call.arguments;

    if (call.method == 'connectResponse') {
      if (arg["status"] == SSHConnectionStatusKeys.CONNECTED) {
        onConnectedResult!();
      } else if (arg["status"] == SSHConnectionStatusKeys.CONNECTING) {
        onConnectingResult!();
      } else if (arg["status"] == SSHConnectionStatusKeys.DISCONNECTED) {
        onDisconnectedResult!();
        bool? error = arg["error"];
        if (error != null && error) onError!();
      }
    }
  }

  channel.setMethodCallHandler(methodCallReceiver);
}