Spec-Zone.ru › Dart 2

dart:core

padLeft abstract method

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

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

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

const string = 'D';
print(string.padLeft(4)); // '   D'
print(string.padLeft(2, 'x')); // 'xD'
print(string.padLeft(4, 'y')); // 'yyyD'
print(string.padLeft(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.

Implementation

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

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-core/String/padLeft.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API