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 sparkline5;
  if (sparkline7d.length==0)
    sparkline5 = "sparkline empty/disabled";
  else
    sparkline5 = sparkline7d
        .sublist(0, sparkline7d.length > 5 ? 5 : sparkline7d.length)
        .join(',');

  String perChange = priceChangePercentage1hInCurrency.toString() +
      " - " +
      priceChangePercentage24hInCurrency.toString() +
      " - " +
      priceChangePercentage7dInCurrency.toString() +
      " - " +
      priceChangePercentage30dInCurrency.toString() +
      " - " +
      priceChangePercentage200dInCurrency.toString() +
      "- ";
  return "id: $id, symbol: $symbol, current_price: $currentPrice, market_cap: $marketCap, lastupdated: $lastUpdated, sparkline: $sparkline5, per_change_1h_1d_7d_30d_200d: $perChange";
}