expressiveChoiceWidth function
face, a choice's field: in a window ExpressiveSelect.wideFrom or
wider, at most ExpressiveSelect.wideMaxWidth wide at its column's start
(a form grid's narrower cell bounds it as before); on a phone, its
column's width.
fitContent, never narrower than face needs for its content on one
line (a segmented control's labels, read from its intrinsic width; its
segments must answer intrinsics).
Implementation
Widget expressiveChoiceWidth(
BuildContext context,
Widget face, {
bool fitContent = false,
}) {
if (MediaQuery.sizeOf(context).width < ExpressiveSelect.wideFrom) {
return face;
}
// Its own height too: offered more (a Center's, a dialog's), it stays
// the control's height.
return Align(
alignment: AlignmentDirectional.centerStart,
widthFactor: 1,
heightFactor: 1,
child: fitContent
? _ControlWidth(child: face)
: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: ExpressiveSelect.wideMaxWidth,
),
child: face,
),
);
}