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) {

    var left = padding.left == 0 ? 0 : padding.left * scale;
    var top = padding.top == 0 ? 0 : padding.top * scale;
    var right = padding.right == 0 ? 0 : padding.right * scale;
    var bottom = padding.bottom == 0 ? 0 : padding.bottom * scale;

    var responsiveLeftTooSmall = left < 0;
    var newLeft = (responsiveLeftTooSmall ? 0 : left).toDouble();
    if(responsiveLeftTooSmall) print('$this left too small ($left), improper inset used newLeft: $newLeft');

    var responsiveTopTooSmall = top < 0;
    var newTop = (responsiveTopTooSmall ? 0 : top).toDouble();
    if(responsiveTopTooSmall) print('$this top too small ($top), improper inset used newTop: $newTop');

    var responsiveRightTooSmall = right < 0;
    var newRight = (responsiveRightTooSmall ? 0 : right).toDouble();
    if(responsiveRightTooSmall) print('$this right too small ($right), improper inset used newRight: $newRight');

    var responsiveBottomTooSmall = bottom < 0;
    var newBottom = (responsiveBottomTooSmall ? 0 : bottom).toDouble();
    if(responsiveBottomTooSmall) print('$this bottom too small ($bottom), improper inset used newBottom: $newBottom');

    return Padding(
        padding: EdgeInsets.fromLTRB(newLeft, newTop, newRight, newBottom),
        child: child ?? Container(),
    );
}