toString method

  1. @override
String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString() {
  final buffer = StringBuffer();
  const separator = '\n~~~~~~~~~';

  buffer
    // Objective
    ..writeln('$separator Objective')
    ..writeln(_objective.toString())
    // Tableau
    ..writeln('$separator Tableau');

  _rows.forEach((symbol, row) {
    buffer.writeln('$symbol | $row');
  });

  // Infeasible
  buffer.writeln('$separator Infeasible');
  _infeasibleRows.forEach(buffer.writeln);

  // Variables
  buffer.writeln('$separator Variables');
  _vars.forEach((variable, symbol) {
    buffer.writeln('$variable = $symbol');
  });

  // Edit Variables
  buffer.writeln('$separator Edit Variables');
  _edits.forEach((variable, editinfo) {
    buffer.writeln(variable);
  });

  // Constraints
  buffer.writeln('$separator Constraints');
  _constraints.forEach((constraint, tag) {
    buffer.writeln(constraint);
  });

  return buffer.toString();
}