toString method

  1. @override
String toString([
  1. Map? args
])
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([Map? args]) {
  //arguments ??= args;
  if (playerName != null && playerName!.isNotEmpty) return playerName!;
  var ret = '@$selector';

  if (arguments.isNotEmpty) {
    ret += '[';
    for (var key in arguments.keys) {
      if (arguments[key] is List) {
        final list = arguments[key] as List;
        if (list.isEmpty) continue;

        ret += list.map((item) => _addArg(item, key)).join(',');

        if (key != arguments.keys.last) ret += ',';
      } else {
        ret += _addArg(arguments[key], key);
        if (key != arguments.keys.last) ret += ',';
      }
    }
    ret += ']';
  }
  return ret;
}