constrained method

Widget constrained({
  1. Key? key,
  2. double? width,
  3. double? height,
  4. double minWidth = 0.0,
  5. double maxWidth = double.infinity,
  6. double minHeight = 0.0,
  7. double maxHeight = double.infinity,
})

约束

Implementation

Widget constrained({
  Key? key,
  double? width,
  double? height,
  double minWidth = 0.0,
  double maxWidth = double.infinity,
  double minHeight = 0.0,
  double maxHeight = double.infinity,
}) {
  BoxConstraints constraints = BoxConstraints(
    minWidth: minWidth,
    maxWidth: maxWidth,
    minHeight: minHeight,
    maxHeight: maxHeight,
  );
  constraints = (width != null || height != null)
      ? constraints.tighten(width: width, height: height)
      : constraints;
  return ConstrainedBox(
    key: key,
    constraints: constraints,
    child: this,
  );
}