Code I am using:
pw.Text('\u20B9 $value',textAlign: pw.TextAlign.center)
Expected output:
₹ 123456 7891011
(rupee symbol + white space and then the text which is center aligned)
Issue:
If the text is too long, then it moves to second line but it breaks directly to second line like this:
₹ 1234567891011
Closet Alternative that I found:
pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.center,
crossAxisAlignment: pw.CrossAxisAlignment.start,
mainAxisSize: pw.MainAxisSize.min,
children: [
pw.Text(
'\u20B9 ',
textAlign: pw.TextAlign.center,
style: pw.TextStyle(
font: interSemiBold,
fontFallback: fontFallback,
fontSize: figmaToPdf(14),
fontWeight: pw.FontWeight.bold,
color: isAlert ? pdfDarkRedColor : pdfDarkCharcoalBlack,
),
),
pw.SizedBox(width: 1),
pw.Flexible(
child: pw.Text(
value,
textAlign: pw.TextAlign.center,
style: pw.TextStyle(
font: interSemiBold,
fontFallback: fontFallback,
fontSize: figmaToPdf(14),
fontWeight: pw.FontWeight.bold,
color: isAlert ? pdfDarkRedColor : pdfDarkCharcoalBlack,
),
),
),
],
),
Issue with this code is that when text goes to new line it is centered excluding the rupee symbol because the new line will start after the rupee symbol and hence it does not look centered.
I have also used many white space Unicodes like this: \u2009, \u00A0, RichText Widget but it does not work and makes the amount to move to new line.
Packages which I am using:
pdf: 3.11.3
printing: ^5.11.1
Font which I am using:
Inter_18pt-SemiBold.ttf