box method Null safety
x, y, w and h are in cm
Implementation
Widget box(final Rect pos, final Widget child) {
final double dx = (pos.width >= width) ? 0 : pos.left / (width - pos.width);
final double dy =
(pos.height >= height) ? 0 : pos.top / (height - pos.height);
return Align(
alignment: FractionalOffset(dx, dy),
child: FractionallySizedBox(
widthFactor: pos.width / width,
heightFactor: pos.height / height,
child: child));
}