messureText method
Implementation
double messureText(Characters? text, {double? width, TextStyle? style}) {
if (isNullOrEmpty(text)) return 0;
style ??= _defaultStyle;
double sumWidth = 0;
double? currentWidth;
for (var ch in text!) {
currentWidth = cachedCharWidth[ch];
if (currentWidth == null) {
textPainter.text = TextSpan(
text: ch,
style: style,
);
textPainter.layout(maxWidth: currentWidth ?? double.infinity, minWidth: 0);
currentWidth = textPainter.size.width;
cachedCharWidth[ch] = currentWidth;
}
sumWidth += currentWidth;
if (width!=null && sumWidth > width) {
return currentWidth;
}
}
return sumWidth;
}