getResponsiveWidget method

  1. @override
Widget getResponsiveWidget(
  1. BuildContext context,
  2. ScreenType screenType,
  3. double scale
)
override

Implementation

@override
Widget getResponsiveWidget(BuildContext context, ScreenType screenType, double scale) {

    double? newWidth;
    double? newHeight;
    var hasConstraints = has('constraints');
    var hasWidth = has('width');
    var hasHeight = has('height');

    if(hasConstraints) {
      var constraints = get('constraints') as BoxConstraints;
      newWidth = constraints.maxWidth * scale;
      newHeight = constraints.maxHeight * scale;
    } else if(hasWidth || hasHeight) {
      newWidth = hasWidth ? get('width') * scale : null;
      newHeight = hasHeight ? get('height') * scale : null;
    } else {
      newWidth = null;
      newHeight = null;
    }

    return Container(
        child: child,
        width: newWidth,
        height: newHeight,
        key: get('key'),
        alignment: get('alignment'),
        padding: get('padding'),
        color: get('color'),
        decoration: get('decoration'),
        foregroundDecoration: get('foregroundDecoration'),
        margin: get('margin'),
        transform: get('transform'),
        clipBehavior: get('clipBehavior'),
    );
}