Dart : pad String

Dr_Skele·2023년 3월 10일
0

Dart

목록 보기
5/5

Formatting string in dart is not so easy.
In other languages, string format exists and you can format complex strings with just one line of code.
Sadly, dart doesn't have one like the others.

But luckily, padding characters in string can be done quite easily.

print('9'.padLeft(2, '0')); // '09'

String type supports extension methods 'padLeft' and 'padRight', which can be used to pad characters on existing strings.

reference : https://api.flutter.dev/flutter/dart-core/String/padLeft.html

profile
Tireless And Restless Debugging In Source : TARDIS

0개의 댓글