build method

  1. @override
Widget build(
  1. Context context
)
override

Implementation

@override
pw.Widget build(pw.Context context) {
  final inherited = pw.Theme.of(context).defaultTextStyle;
  final runs = flattenSpans(text, inherited);
  if (!runs.any((r) => containsBangla(r.text))) return _native();

  // Bangla is present: lay each run out with its own shaper. A single
  // pw.RichText cannot do this, because shaping reorders glyphs across the
  // run and pw measures span-by-span.
  return pw.Wrap(
    crossAxisAlignment: pw.WrapCrossAlignment.end,
    children: <pw.Widget>[
      for (final run in runs)
        BanglaAwareText(
          run.text,
          style: run.style,
          textAlign: textAlign,
          textDirection: textDirection,
          softWrap: softWrap,
          tightBounds: tightBounds,
          textScaleFactor: textScaleFactor,
          overflow: overflow,
        ),
    ],
  );
}