scaleToMaxWidth method
Widget
scaleToMaxWidth({
- required BuildContext context,
- double maxWidth = 400,
- double factor = 1.0,
Scales the widget conditionally based on a maximum width.
Implementation
Widget scaleToMaxWidth({
required BuildContext context,
double maxWidth = 400,
double factor = 1.0,
}) {
final screenWidth = MediaQuery.of(context).size.width;
final scale = screenWidth < maxWidth ? (screenWidth / maxWidth) * factor : factor;
return Transform.scale(
scale: scale,
child: this,
);
}