sized method

Widget sized({
  1. double? width,
  2. double? height,
  3. double? size,
})

Wraps this widget in a SizedBox with specified dimensions.

If this widget is already a SizedBox, merges the dimensions.

Parameters:

  • width (double?, optional): Desired width.
  • height (double?, optional): Desired height.

Returns: Widget — sized widget.

Implementation

Widget sized({double? width, double? height, double? size}) {
  if (this is SizedBox) {
    return SizedBox(
      width: width ?? size ?? (this as SizedBox).width,
      height: height ?? size ?? (this as SizedBox).height,
      child: (this as SizedBox).child,
    );
  }
  return SizedBox(
    width: width ?? size,
    height: height ?? size,
    child: this,
  );
}