pad method

String pad(
  1. int length, [
  2. String chars = ' '
])

Implementation

String pad(int length, [String chars = ' ']) {
  var strLength = length != 0 ? this.length : 0;
  if (length == 0 || strLength >= length) {
    return this;
  }
  var mid = (length - strLength) / 2;
  return (_createPadding(mid.floor(), chars) + this + _createPadding(mid.ceil(), chars));
}