onServerResponse method Null safety

void onServerResponse(
  1. List<String> responseTexts
)

Implementation

void onServerResponse(List<String> responseTexts) {
  if (isLogEnabled) {
    for (final responseText in responseTexts) {
      log(responseText, isClient: false);
    }
  }
  final response = SmtpResponse(responseTexts);
  final cmd = _currentCommand;
  if (cmd != null) {
    try {
      final next = cmd.next(response);
      if (next?.text != null) {
        writeText(next!.text!);
      } else if (next?.data != null) {
        writeData(next!.data!);
      } else if (cmd.isCommandDone(response)) {
        if (response.isFailedStatus) {
          cmd.completer.completeError(SmtpException(this, response));
        } else {
          cmd.completer.complete(response);
        }
        //_log("Done with command ${_currentCommand.command}");
        _currentCommand = null;
      }
    } catch (exception, stackTrace) {
      log('Error proceeding to nextCommand: $exception');
      _currentCommand?.completer.completeError(exception, stackTrace);
      _currentCommand = null;
    }
  }
}