operator + method Null safety

Evaluation operator +(
  1. Evaluation? other
)

Combines two evaluation results.

The reason will be concatenated with a newline, and passed will be combined with an && operator.

Implementation

Evaluation operator +(Evaluation? other) {
  if (other == null) {
    return this;
  }

  final StringBuffer buffer = StringBuffer();
  if (reason != null) {
    buffer.write(reason);
    buffer.write(' ');
  }
  if (other.reason != null) {
    buffer.write(other.reason);
  }
  return Evaluation._(
    passed && other.passed,
    buffer.isEmpty ? null : buffer.toString(),
  );
}