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() {
  if (_start == 0.0 && _end == 0.0) {
    if (_left == 0.0 && _right == 0.0 && _top == 0.0 && _bottom == 0.0) {
      return 'EdgeInsets.zero';
    }
    if (_left == _right && _right == _top && _top == _bottom) {
      return 'EdgeInsets.all(${_left.toStringAsFixed(1)})';
    }
    return 'EdgeInsets(${_left.toStringAsFixed(1)}, '
        '${_top.toStringAsFixed(1)}, '
        '${_right.toStringAsFixed(1)}, '
        '${_bottom.toStringAsFixed(1)})';
  }
  if (_left == 0.0 && _right == 0.0) {
    return 'EdgeInsetsDirectional(${_start.toStringAsFixed(1)}, '
        '${_top.toStringAsFixed(1)}, '
        '${_end.toStringAsFixed(1)}, '
        '${_bottom.toStringAsFixed(1)})';
  }
  return 'EdgeInsets(${_left.toStringAsFixed(1)}, '
      '${_top.toStringAsFixed(1)}, '
      '${_right.toStringAsFixed(1)}, '
      '${_bottom.toStringAsFixed(1)})'
      ' + '
      'EdgeInsetsDirectional(${_start.toStringAsFixed(1)}, '
      '0.0, '
      '${_end.toStringAsFixed(1)}, '
      '0.0)';
}