fluent2KeepsOwnWidth function

Widget fluent2KeepsOwnWidth(
  1. BuildContext context, {
  2. required Widget child,
  3. double content = 0,
})

child (a select's or a combobox's trigger): under fluent2RoomyFrom at least 250 and its column's width, as a phone's form runs; from there as wide as its content (its widest words with its room, chevron and strokes), at least 250 (Fluent's Dropdown) and at most fluent2ControlMax, never wider than its cell, at the cell's start. Its list, anchored to child, matches it. Given room to choose, its box is that width alone, so a form field's merged node (and the box a screen reader outlines) is the trigger a tap reaches, not the column.

Implementation

Widget fluent2KeepsOwnWidth(
  BuildContext context, {
  required Widget child,
  double content = 0,
}) {
  if (!fluent2Roomy(context)) {
    return ConstrainedBox(
      constraints: const BoxConstraints(minWidth: 250),
      child: child,
    );
  }
  return Align(
    alignment: AlignmentDirectional.centerStart,
    widthFactor: 1,
    child: ConstrainedBox(
      constraints: BoxConstraints(
        maxWidth: content.clamp(250.0, fluent2ControlMax),
      ),
      child: child,
    ),
  );
}