@@ -74,6 +74,12 @@ class ResponsiveWrapper extends StatefulWidget {
7474 final bool defaultScale;
7575 final double defaultScaleFactor;
7676
77+ final double minWidthLandscape;
78+ final double ? maxWidthLandscape;
79+ final String ? defaultNameLandscape;
80+ final bool defaultScaleLandscape;
81+ final double defaultScaleFactorLandscape;
82+
7783 /// An optional background widget to insert behind
7884 /// the responsive content. The background widget
7985 /// expands to fill the entire space of the wrapper and
@@ -109,6 +115,11 @@ class ResponsiveWrapper extends StatefulWidget {
109115 this .defaultName,
110116 this .defaultScale = false ,
111117 this .defaultScaleFactor = 1 ,
118+ this .minWidthLandscape = 450 ,
119+ this .maxWidthLandscape,
120+ this .defaultNameLandscape,
121+ this .defaultScaleLandscape = false ,
122+ this .defaultScaleFactorLandscape = 1 ,
112123 this .background,
113124 this .backgroundColor,
114125 this .mediaQueryData,
@@ -130,6 +141,11 @@ class ResponsiveWrapper extends StatefulWidget {
130141 String ? defaultName,
131142 bool defaultScale = false ,
132143 double defaultScaleFactor = 1 ,
144+ double minWidthLandscape = 450 ,
145+ double ? maxWidthLandscape,
146+ String ? defaultNameLandscape,
147+ bool defaultScaleLandscape = false ,
148+ double defaultScaleFactorLandscape = 1 ,
133149 Widget ? background,
134150 Color ? backgroundColor,
135151 MediaQueryData ? mediaQueryData,
@@ -146,6 +162,11 @@ class ResponsiveWrapper extends StatefulWidget {
146162 defaultName: defaultName,
147163 defaultScale: defaultScale,
148164 defaultScaleFactor: defaultScaleFactor,
165+ minWidthLandscape: minWidthLandscape,
166+ maxWidthLandscape: maxWidthLandscape,
167+ defaultNameLandscape: defaultNameLandscape,
168+ defaultScaleLandscape: defaultScaleLandscape,
169+ defaultScaleFactorLandscape: defaultScaleFactorLandscape,
149170 background: background,
150171 backgroundColor: backgroundColor,
151172 mediaQueryData: mediaQueryData,
@@ -205,17 +226,17 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
205226 // Special 0 width condition.
206227 if (activeBreakpointSegment.responsiveBreakpoint.breakpoint == 0 ) return 0 ;
207228 // Check if screenWidth exceeds maxWidth.
208- if (widget. maxWidth != null && windowWidth > widget. maxWidth! ) {
229+ if (maxWidth != null && windowWidth > maxWidth! ) {
209230 // Check if there is an active breakpoint with autoScale set to true.
210- if (activeBreakpointSegment.breakpoint >= widget. maxWidth! &&
231+ if (activeBreakpointSegment.breakpoint >= maxWidth! &&
211232 activeBreakpointSegment.responsiveBreakpoint.isAutoScale) {
212233 // Proportionally scaled width that exceeds maxWidth.
213- return widget. maxWidth! +
234+ return maxWidth! +
214235 (windowWidth -
215236 activeBreakpointSegment.responsiveBreakpoint.breakpoint);
216237 } else {
217238 // Max Width reached. Return Max Width because no breakpoint is active.
218- return widget. maxWidth! ;
239+ return maxWidth! ;
219240 }
220241 }
221242
@@ -228,12 +249,12 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
228249 // Special 0 height condition.
229250 if (activeBreakpointSegment.responsiveBreakpoint.breakpoint == 0 ) return 0 ;
230251 // Check if screenWidth exceeds maxWidth.
231- if (widget. maxWidth != null ) if (windowWidth > widget. maxWidth! ) {
252+ if (maxWidth != null ) if (windowWidth > maxWidth! ) {
232253 // Check if there is an active breakpoint with autoScale set to true.
233- if (activeBreakpointSegment.breakpoint > widget. maxWidth! &&
254+ if (activeBreakpointSegment.breakpoint > maxWidth! &&
234255 activeBreakpointSegment.responsiveBreakpoint.isAutoScale) {
235256 // Scale screen height by the amount the width was scaled.
236- return windowHeight / (screenWidth / widget. maxWidth! );
257+ return windowHeight / (screenWidth / maxWidth! );
237258 }
238259 }
239260
@@ -251,9 +272,9 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
251272 /// that breakpoint's logic.
252273 /// 2. If no breakpoint is found, check if the [screenWidth]
253274 /// is smaller than the smallest breakpoint. If so,
254- /// follow [widget. defaultScale] behavior to resize.
275+ /// follow [defaultScale] behavior to resize.
255276 /// 3. There are no breakpoints set. Resize using
256- /// [widget. defaultScale] behavior and [widget. minWidth] .
277+ /// [defaultScale] behavior and [minWidth] .
257278 double scaledWidth = 0 ;
258279 double getScaledWidth () {
259280 // If widget should resize, use screenWidth.
@@ -262,9 +283,8 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
262283 activeBreakpointSegment.responsiveBreakpoint.scaleFactor;
263284
264285 // Screen is larger than max width. Scale from max width.
265- if (widget.maxWidth != null ) if (activeBreakpointSegment.breakpoint >
266- widget.maxWidth! )
267- return widget.maxWidth! /
286+ if (maxWidth != null ) if (activeBreakpointSegment.breakpoint > maxWidth! )
287+ return maxWidth! /
268288 activeBreakpointSegment.responsiveBreakpoint.scaleFactor;
269289
270290 // Return width from breakpoint with scale factor applied.
@@ -284,10 +304,10 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
284304 /// resize, nothing more needs to be done.
285305 /// 2. If the widget should scale, calculate the screen
286306 /// aspect ratio and return the proportional height.
287- /// 3. If there are no active breakpoints and [widget. defaultScale]
307+ /// 3. If there are no active breakpoints and [defaultScale]
288308 /// is resize, nothing more needs to be done.
289309 /// 4. Return calculated proportional height with
290- /// [widget. minWidth] .
310+ /// [minWidth] .
291311 double scaledHeight = 0 ;
292312 double getScaledHeight () {
293313 // If widget should resize, use screenHeight.
@@ -297,8 +317,7 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
297317
298318 // Screen is larger than max width. Calculate height
299319 // from max width.
300- if (widget.maxWidth != null ) if (activeBreakpointSegment.breakpoint >
301- widget.maxWidth! ) {
320+ if (maxWidth != null ) if (activeBreakpointSegment.breakpoint > maxWidth! ) {
302321 return screenHeight /
303322 activeBreakpointSegment.responsiveBreakpoint.scaleFactor;
304323 }
@@ -420,7 +439,7 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
420439
421440 /// Fullscreen is enabled if maxWidth is not set.
422441 /// Default fullscreen enabled.
423- get fullscreen => widget. maxWidth == null ;
442+ get fullscreen => maxWidth == null ;
424443
425444 Orientation get orientation => (windowWidth > windowHeight)
426445 ? Orientation .landscape
@@ -436,6 +455,23 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
436455 (widget.landscapePlatforms ?? _landscapePlatforms)
437456 .contains (Theme .of (context).platform);
438457
458+ bool get isLandscape =>
459+ orientation == Orientation .landscape &&
460+ isLandscapePlatform &&
461+ widget.breakpointsLandscape != null ;
462+
463+ double get minWidth =>
464+ isLandscape ? widget.minWidthLandscape : widget.minWidth;
465+ double ? get maxWidth =>
466+ isLandscape ? widget.maxWidthLandscape : widget.maxWidth;
467+ String ? get defaultName =>
468+ isLandscape ? widget.defaultNameLandscape : widget.defaultName;
469+ bool get defaultScale =>
470+ isLandscape ? widget.defaultScaleLandscape : widget.defaultScale;
471+ double get defaultScaleFactor => isLandscape
472+ ? widget.defaultScaleFactorLandscape
473+ : widget.defaultScaleFactor;
474+
439475 /// Calculate updated dimensions.
440476 void setDimensions () {
441477 devicePixelRatio = getDevicePixelRatio ();
@@ -467,12 +503,12 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
467503 List <ResponsiveBreakpoint > breakpoints) {
468504 // Seed breakpoint based on config values.
469505 ResponsiveBreakpoint defaultBreakpoint = ResponsiveBreakpoint (
470- breakpoint: widget. minWidth,
471- name: widget. defaultName,
472- behavior: widget. defaultScale
506+ breakpoint: minWidth,
507+ name: defaultName,
508+ behavior: defaultScale
473509 ? ResponsiveBreakpointBehavior .AUTOSCALE
474510 : ResponsiveBreakpointBehavior .RESIZE ,
475- scaleFactor: widget. defaultScaleFactor);
511+ scaleFactor: defaultScaleFactor);
476512 return getBreakpointSegments (breakpoints, defaultBreakpoint);
477513 }
478514
@@ -492,9 +528,6 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
492528 breakpointSegments.clear ();
493529 breakpoints.addAll (getActiveBreakpoints ());
494530 breakpointSegments.addAll (calcBreakpointSegments (breakpoints));
495- print ('Breakpoints: ${(widget .landscapePlatforms ?? _landscapePlatforms )}' );
496- print ('Theme: ${Theme .of (context ).platform }' );
497- print (breakpointSegments);
498531 }
499532
500533 @override
@@ -538,7 +571,6 @@ class _ResponsiveWrapperState extends State<ResponsiveWrapper>
538571 @override
539572 void didChangeMetrics () {
540573 super .didChangeMetrics ();
541- print ('didChangeMetrics ${windowWidth }' );
542574 setBreakpoints ();
543575 // When physical dimensions change, update state.
544576 // The required MediaQueryData is only available
0 commit comments