responsive_builder icon indicating copy to clipboard operation
responsive_builder copied to clipboard

Pass SizingInformation to the ScreenTypeLayout builders

Open BenjiFarquhar opened this issue 2 years ago • 0 comments

Hi,

I see in the build method of ScreenTypeLayout, that we have access to the SizingInformation but are not passing it to each builder:

  @override
  Widget build(BuildContext context) {
    return ResponsiveBuilder(
      breakpoints: breakpoints,
      builder: (context, sizingInformation) {
        // If we're at desktop size
        if (sizingInformation.deviceScreenType == DeviceScreenType.desktop) {
          // If we have supplied the desktop layout then display that
          if (desktop != null) return desktop!(context);
          // If no desktop layout is supplied we want to check if we have the size below it and display that
          if (tablet != null) return tablet!(context);
        }

        if (sizingInformation.deviceScreenType == DeviceScreenType.tablet) {
          if (tablet != null) return tablet!(context);
        }

        if (sizingInformation.deviceScreenType == DeviceScreenType.watch &&
            watch != null) {
          return watch!(context);
        }

        // If none of the layouts above are supplied or we're on the mobile layout then we show the mobile layout
        return mobile(context);
      },

Please pass it to the passed in builders, as right now we need to add our own ResponsiveBuilder to get the SizingInformation while the build method of ScreenTypeLayout is already doing that.

P.S. You may as well do the same for RefinedLayoutBuilder.

BTW, I've done it in a fork.

BenjiFarquhar avatar Aug 06 '22 05:08 BenjiFarquhar