widthOf static method
The width EmojiText lays text out at on one line under style.
Implementation
static double widthOf(BuildContext context, String text, TextStyle style) {
final painter = TextPainter(
text: TextSpan(
style: MediaQuery.boldTextOf(context)
? style.merge(const TextStyle(fontWeight: FontWeight.bold))
: style,
children: [_spanOf(text, null, EmojiFont.of(context))],
),
textDirection: Directionality.of(context),
textScaler: MediaQuery.textScalerOf(context),
locale: Localizations.maybeLocaleOf(context),
maxLines: 1,
)..layout();
try {
return painter.maxIntrinsicWidth;
} finally {
painter.dispose();
}
}