toString method

  1. @override
String toString()

Returns a string representation of the current operation.

Implementation

@override
String toString() {
  late String operandsString;

  if (operands.isEmpty) {
    return '';
  }

  if (operands.length > 1) {
    operandsString = operands.join(operator ?? '');

    if (isLastOperandPercent) {
      operandsString += '%';
    }
  } else {
    operandsString = operands[0] + (operator ?? '');
  }

  return result != null ? '$operandsString=$result' : operandsString;
}