applyConstraints method
This routine applies the given constraints to the supplied view and then returns a widget with the view wrapped in those constraints
Implementation
Widget applyConstraints(Widget view, Constraints constraints)
{
// If no constraints are specified
// return the view
if (constraints.isEmpty) return view;
// Apply min and max constraints to the view only if
// they are supplied and have not already been applied using
// width and/or height
if ((constraints.minWidth ?? 0) > 0 ||
(constraints.maxWidth ?? double.infinity) < double.infinity ||
(constraints.minHeight ?? 0) > 0 ||
(constraints.maxHeight ?? double.infinity) < double.infinity)
{
var box = BoxConstraints(minWidth: constraints.minWidth ?? 0, maxWidth: constraints.maxWidth ?? double.infinity, minHeight: constraints.minHeight ?? 0, maxHeight: constraints.maxHeight ?? double.infinity);
view = ConstrainedBox(child: view, constraints: box);
}
return view;
}