LineWrapperHyphen constructor

LineWrapperHyphen(
  1. List<TextPartToken> tokens,
  2. Text _text,
  3. TextStyle _style,
  4. double _maxWidth,
  5. String _hyphen,
)

Constructor.

Implementation

LineWrapperHyphen(List<TextPartToken> tokens, this._text, this._style,
    this._maxWidth, this._hyphen) {
  final Map<String, Size> tokensWidthCache = {};
  _tokenIter = TokenIterator(tokens);

  _painter = TextPainter(
    textDirection: _text.textDirection ?? TextDirection.ltr,
    maxLines: _text.maxLines,
    textScaleFactor: _text.textScaleFactor ?? 1.0,
    locale: _text.locale,
    textAlign: _text.textAlign ?? TextAlign.start,
    textHeightBehavior: _text.textHeightBehavior,
    textWidthBasis: _text.textWidthBasis ?? TextWidthBasis.parent,
  );

  for (final TextPartToken part in tokens) {
    if (part is WordToken) {
      for (final WordPartToken p in part.parts) {
        _setWidths(p.text, tokensWidthCache, p);
      }
    } else if (part is TabsAndSpacesToken) {
      _setWidths(part.text, tokensWidthCache, part);
    } else if (part is NewlineToken) {
      part.sizeHyphen = const Size(0, 0);
      part.sizeNoHyphen = const Size(0, 0);
      part.sizeCurrent = const Size(0, 0);
    }
  }

  // print('=== CACHE: ${tokensWidthCache}');
}