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() {
  var tag = target;
  var val1 = value1;
  var val2 = value2;
  if (val1 is DateTime) {
    val1 = val1.toIso8601String();
  }
  if (val2 is DateTime) {
    val2 = val2.toIso8601String();
  }
  if (val1 is Pattern) {
    val1 = val1.toString();
  }
  if (val2 is Pattern) {
    val2 = val2.toString();
  }
  val1 = '"value":"$val1"';
  val2 = val2 != null ? ',"secondValue":"$val2"' : '';
  return '&metadata[keyvalues][$tag]={$val1$val2,"op"'
      ':"$operation"}';
}