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() {
  String ret = '[ ID3MetaInfo ]\n';
  ret += "- Range: $range\n";
  String tranferValue(dynamic value, String key) {
    String ret = '';
    if (value is _ID3MetadataValue) {
      ret += "- $key: ${value.toString()}\n";
    } else {
      if (value is Map) {
        for (var element in value.entries) {
          final key = element.key;
          final value = element.value;
          ret += tranferValue(value, key);
        }
      } else if (value is List) {
        for (var element in value) {
          ret += tranferValue(element, key);
        }
      } else {
        ret += "- $key: $value\n";
      }
    }
    return ret;
  }

  for (var element in _metadata.entries) {
    final key = element.key;
    final value = element.value;
    ret += "== $key ==\n";
    ret += tranferValue(value, key);
  }
  ret += "=========> All data received <=======";
  return ret;
}