comicOwnSize function
Widget
comicOwnSize({
- double? width,
- double? height,
- AlignmentGeometry alignment = AlignmentDirectional.topStart,
- required Widget child,
A part with its own size keeps it, whatever its parent asks. A stretching Column or Row hands tight constraints, which a
SizedBox can't refuse: a paint that reads its declared size and a Center that reads the real width come apart. Here the
part stands at alignment in the room (the start edge unless it is centred by design: left in LTR, mirrored in RTL) and,
if the room is smaller than the part, scales down whole. Give one side, or none, for a part whose other side follows its
content.
Implementation
Widget comicOwnSize({
double? width,
double? height,
AlignmentGeometry alignment = AlignmentDirectional.topStart,
required Widget child,
}) {
final box = SizedBox(width: width, height: height, child: child);
return width != null && height != null
? FittedBox(fit: BoxFit.scaleDown, alignment: alignment, child: box)
: Align(
alignment: alignment,
widthFactor: 1,
heightFactor: 1,
child: box,
);
}