padRight abstract method

String padRight(
  1. int width,
  2. [String padding = ' ']

Pads this string on the right if it is shorter than width.

Returns a new string that appends padding after this string one time for each position the length is less than width.

const string = 'D';
print(string.padRight(4)); // 'D    '
print(string.padRight(2, 'x')); // 'Dx'
print(string.padRight(4, 'y')); // 'Dyyy'
print(string.padRight(4, '>>')); // 'D>>>>>>'

If width is already smaller than or equal to this.length, no padding is added. A negative width is treated as zero.

If padding has length different from 1, the result will not have length width. This may be useful for cases where the padding is a longer string representing a single character, like " " or "\u{10002}". In that case, the user should make sure that this.length is the correct measure of the string's length.


String padRight(int width, [String padding = ' ']);