Will Custom SizedBox cause any UI problems?

45 Views Asked by At

I've created a custom sizedBox and used the Screenutil extension for responsive design. when wrapping a widget in this custom sizedBox  by providing only with or height, The widget is disappearing.There is no error is the console. when giving both (with and height), it's appearing. but when using SizedBox instead of a custom sizedBox ,widget is appearing even give only with or height.


class SBox extends StatelessWidget {
  const SBox({Key? key, this.h, this.w, this.child}) : super(key: key);
  final double? h;
  final double? w;
  final Widget? child;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: (h ?? 0.0).h,
      width: (w ?? 0.0).w,
      child: child,
    );
  }
}

Why is it happening? Is there any problem with my custom sizedBox? Will this cause any problem?

0

There are 0 best solutions below