|
1 | | -# Responsive Wrapper |
| 1 | + |
| 2 | +# Responsive Framework |
| 3 | +[](https://github.com/Codelessly/ResponsiveFramework) [](https://pub.dev/packages/responsive_Framework) [](https://github.com/Codelessly/ResponsiveFramework) [](https://github.com/Codelessly/ResponsiveFramework/issues) [](https://github.com/Codelessly/ResponsiveFramework) |
| 4 | + |
| 5 | +Responsive Framework adapts your UI to different screen sizes automatically. Create your UI once and have it display correctly on mobile, tablet, and desktop! |
| 6 | +### The Problem |
| 7 | +Supporting multiple display sizes often means recreating the same layout multiple times with the traditional _Bootstrap_ approach. This is time consuming, frustrating and repetitive work. Furthermore, getting your designs pixel perfect is near impossible and editing becomes a nightmare. |
| 8 | +### The Solution |
| 9 | +Use Responsive Framework to automatically resize or scale your UI based on _breakpoints_. |
| 10 | + |
| 11 | +```dart |
| 12 | +ResponsiveWrapper( |
| 13 | + child, |
| 14 | + breakpoints: [ |
| 15 | + ResponsiveBreakpoint(breakpoint: 600, name: MOBILE), |
| 16 | + ResponsiveBreakpoint(breakpoint: 800, name: TABLET), |
| 17 | + ResponsiveBreakpoint(breakpoint: 1200, name: DESKTOP), |
| 18 | + ], |
| 19 | +) |
| 20 | +``` |
| 21 | + |
| 22 | + |
| 23 | +## Resize vs Scale |
| 24 | + |
| 25 | +To easily adapt to a wide variety of screen sizes, set breakpoints to proportionally scale or resize a layout. |
| 26 | + |
| 27 | +> ResponsiveBreakpoint(breakpoint: 600, **scale: true**) |
| 28 | +
|
| 29 | +This eliminates the need to manually adapt layouts to mobile, tablet, and desktop. |
| 30 | + |
| 31 | +To understand the difference between resizing and scaling, take the following example. |
| 32 | +An AppBar widget looks correct on a phone. When viewed on a desktop however, the AppBar is too short and the title looks too small. This is because Flutter does not scale widgets by default. |
| 33 | +Here is what happens with each behavior: |
| 34 | +1. Resizing (default) - the AppBar's width is double.infinity so it stretches to fill the available width. The Toolbar height is fixed and stays 56dp. |
| 35 | +2. Scaling - the AppBar's width stretches to fill the available width. The height scales proportionally using an aspect ratio automatically calculated from the nearest `ResponsiveBreakpoint`. As the width increases, the height increases proportionally. |
| 36 | + |
| 37 | +## Setting Breakpoints |
| 38 | + |
| 39 | +An arbitrary number of breakpoints can be set. Resizing/scaling behavior can be mixed and matched as below. |
| 40 | + - 1400+: scale on extra large 4K displays so text is still legible and widgets are not spaced too far apart. |
| 41 | + - 1400-800: resize on desktops to use available space. |
| 42 | + - 800-600: scale on tablets to avoid elements appearing too small. |
| 43 | + - 600-350: resize on phones for native widget sizes. |
| 44 | + - below 350: resize on small screens to avoid cramp and overflow errors. |
0 commit comments