TF-4171 Display tag in mailbox list
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WidgetUtils {
|
||||
WidgetUtils._();
|
||||
|
||||
static double measureTextWidth({
|
||||
required String text,
|
||||
double fallbackWidth = 0,
|
||||
TextStyle? style,
|
||||
Locale? locale,
|
||||
double? horizontalPadding,
|
||||
}) {
|
||||
try {
|
||||
final textPainter = TextPainter(
|
||||
text: TextSpan(
|
||||
text: text,
|
||||
style: style,
|
||||
locale: locale,
|
||||
),
|
||||
maxLines: 1,
|
||||
textDirection: TextDirection.ltr,
|
||||
)..layout();
|
||||
|
||||
if (horizontalPadding != null) {
|
||||
return textPainter.width + horizontalPadding * 2;
|
||||
} else {
|
||||
return textPainter.width;
|
||||
}
|
||||
} catch (e) {
|
||||
return fallbackWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user