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() {
  final $buf = StringBuffer()..writeln('Coupon(');
  if (amountOff != null) {
    $buf
      ..writeln()
      ..write('  amount_off: ')
      ..write(amountOff)
      ..write(',');
  }
  if (appliesTo != null) {
    $buf
      ..writeln()
      ..write('  applies_to: ')
      ..write(appliesTo)
      ..write(',');
  }
  $buf
    ..writeln()
    ..write('  created: ')
    ..write(created)
    ..write(',');
  if (currency != null) {
    $buf
      ..writeln()
      ..write('  currency: ')
      ..write(currency)
      ..write(',');
  }
  if (currencyOptions != null) {
    $buf
      ..writeln()
      ..write('  currency_options: ')
      ..write(currencyOptions)
      ..write(',');
  }
  $buf
    ..writeln()
    ..write('  duration: ')
    ..write(duration)
    ..write(',');
  if (durationInMonths != null) {
    $buf
      ..writeln()
      ..write('  duration_in_months: ')
      ..write(durationInMonths)
      ..write(',');
  }
  $buf
    ..writeln()
    ..write('  id: ')
    ..write(id)
    ..write(',');
  $buf
    ..writeln()
    ..write('  livemode: ')
    ..write(livemode)
    ..write(',');
  if (maxRedemptions != null) {
    $buf
      ..writeln()
      ..write('  max_redemptions: ')
      ..write(maxRedemptions)
      ..write(',');
  }
  if (metadata != null) {
    $buf
      ..writeln()
      ..write('  metadata: ')
      ..write(metadata)
      ..write(',');
  }
  if (name != null) {
    $buf
      ..writeln()
      ..write('  name: ')
      ..write(name)
      ..write(',');
  }
  $buf
    ..writeln()
    ..write('  object: ')
    ..write(object)
    ..write(',');
  if (percentOff != null) {
    $buf
      ..writeln()
      ..write('  percent_off: ')
      ..write(percentOff)
      ..write(',');
  }
  if (redeemBy != null) {
    $buf
      ..writeln()
      ..write('  redeem_by: ')
      ..write(redeemBy)
      ..write(',');
  }
  $buf
    ..writeln()
    ..write('  times_redeemed: ')
    ..write(timesRedeemed)
    ..write(',');
  $buf
    ..writeln()
    ..write('  valid: ')
    ..write(valid)
    ..write(',');
  $buf.write(')');
  return $buf.toString();
}