computeTargetWidth static method
Implementation
static double computeTargetWidth(
List<SContextMenuItem> buttons, TextStyle style, double screenWidth) {
const double iconAndGap = 24 + 6; // icon + gap
const double horizontalPadding = 16;
final longest = buttons.isEmpty
? labelWidth(SContextMenu.defaultButtonLabel, style)
: buttons
.map((b) => labelWidth(b.label, style))
.fold<double>(0, math.max);
final adaptiveMax = math.min(screenWidth * 0.45, 280.0);
final raw = longest + iconAndGap + horizontalPadding;
return raw.clamp(80.0, adaptiveMax);
}