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() {
  switch (childSignature.value) {
    case 'y':
      var values = children.map((child) => child.asByte()).join(', ');
      return 'DBusArray.byte([$values])';
    case 'b':
      var values = children.map((child) => child.asBoolean()).join(', ');
      return 'DBusArray.boolean([$values])';
    case 'n':
      var values = children.map((child) => child.asInt16()).join(', ');
      return 'DBusArray.int16([$values])';
    case 'q':
      var values = children.map((child) => child.asUint16()).join(', ');
      return 'DBusArray.uint16([$values])';
    case 'i':
      var values = children.map((child) => child.asInt32()).join(', ');
      return 'DBusArray.int32([$values])';
    case 'u':
      var values = children.map((child) => child.asUint32()).join(', ');
      return 'DBusArray.uint32([$values])';
    case 'x':
      var values = children.map((child) => child.asInt64()).join(', ');
      return 'DBusArray.int64([$values])';
    case 't':
      var values = children.map((child) => child.asUint64()).join(', ');
      return 'DBusArray.uint64([$values])';
    case 'd':
      var values = children.map((child) => child.asDouble()).join(', ');
      return 'DBusArray.double([$values])';
    case 's':
      var values =
          children.map((child) => "'${child.asString()}'").join(', ');
      return 'DBusArray.string([$values])';
    case 'o':
      var values =
          children.map((child) => child.asObjectPath().toString()).join(', ');
      return 'DBusArray.objectPath([$values])';
    case 'g':
      var values =
          children.map((child) => child.asSignature().toString()).join(', ');
      return 'DBusArray.signature([$values])';
    case 'v':
      var values = children.map((child) => child.asVariant()).join(', ');
      return 'DBusArray.variant([$values])';
    case 'h':
      var values = children.map((child) => child.asUnixFd()).join(', ');
      return 'DBusArray.unixFd([$values])';
    default:
      var childrenText = <String>[];
      for (var child in children) {
        childrenText.add(child.toString());
      }
      return "$runtimeType($childSignature, [${childrenText.join(', ')}])";
  }
}