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() {
  var buffer = StringBuffer();
  buffer.write("style: {");
  buffer.write("flex-direction: ${flexCSSDirection.toString().toLowerCase()}, ");

  if (flexGrow != 0) buffer.write("flex-grow: $flexGrow, ");

  if (flexBasis != undefined) buffer.write("flex-basis: $flexBasis, ");

  if (flexShrink != 0) buffer.write("flex-shrink: $flexShrink, ");

  if (justifyContent != FlexJustify.flexStart) {
    buffer.write("justify_content: ${enumValueToString(justifyContent).toLowerCase()}, ");
  }

  if (alignContent != FlexAlign.flexStart) {
    buffer.write("align_content: ${enumValueToString(alignContent).toLowerCase()}, ");
  }

  if (alignItems != FlexAlign.stretch) {
    buffer.write("align_items: ${enumValueToString(alignItems).toLowerCase()}, ");
  }

  if (alignSelf != FlexAlign.auto) {
    buffer.write("align_self: ${enumValueToString(alignSelf).toLowerCase()}, ");
  }

  if (flexWrap != FlexWrap.noWrap) {
    buffer.write("wrap: ${enumValueToString(flexWrap).toLowerCase()}, ");
  }

  if (overflow != FlexOverflow.visible) {
    buffer.write("overflow: ${enumValueToString(overflow).toLowerCase()}, ");
  }

  if (positionType != FlexPositionType.relative) {
    buffer.write("positionType: ${enumValueToString(positionType).toLowerCase()}, ");
  }

  if (width != 0) buffer.write("width: $width, ");

  if (height != 0) buffer.write("height: $height, ");

  if (maxWidth != 0) buffer.write("max-width: $maxWidth, ");

  if (maxHeight != 0) buffer.write("max-height: $maxHeight, ");

  if (minWidth != 0) buffer.write("min-height: $minWidth, ");

  if (minHeight != 0) buffer.write("min-height: $minHeight, ");

  buffer.write("}");
  return buffer.toString();
}