responsive_builder
responsive_builder copied to clipboard
Add `isWebOrDesktop` to ResponsiveBuilder
Fixes #31
Fixes the issues on all Desktop platforms when the window is wider than the height and mean it used the tablet sizes.
This change ensures that width=Size.width rather than width=Size.shortest when on Web and Desktop. The code was there in the getDeviceTypes and getRefindedSize but it was either was not configurable and stuck as kIsWeb or had a parameter and defaulted. I have added a parameter to ResponsiveBuilder to allow this to be overridden. Currently, it just defaults to kIsWeb as this was the existing behaviour.
Example
ResponsiveBuilder(
isWebOrDesktop: kIsWeb || Theme.of(context).platform.isDesktop(), // Using an extension function to determine isDesktop
builder: (context, sizingInformation) {
...
}
Extra. If anyone wants the extension function to use the above
extension PlatformCheck on TargetPlatform {
bool isDesktop() {
return [TargetPlatform.macOS, TargetPlatform.windows, TargetPlatform.linux]
.contains(this);
}
}
To use the code in this PR in your app:
responsive_builder:
git:
url: git://github.com/georgeherby/responsive_builder.git
ref: master