Skip to content

Commit 6a2fe42

Browse files
committed
Update ReadMe v1.0.0
1 parent 1a67f2d commit 6a2fe42

1 file changed

Lines changed: 96 additions & 24 deletions

File tree

README.md

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,7 @@
66

77
> ### Responsiveness made simple
88
9-
Responsive Framework adapts your UI to different screen sizes automatically. Create your UI once and have it display pixel perfect on mobile, tablet, and desktop!
10-
11-
### The Problem
12-
Supporting multiple display sizes often means recreating the same layout multiple times. Under the traditional _Bootstrap_ approach, building responsive UI is time consuming, frustrating and repetitive. Furthermore, getting everything pixel perfect is near impossible and simple edits take hours.
13-
14-
![Screenshots](packages/Bad%20Viewport%20Selector%20Animated.gif)
15-
16-
### The Solution
17-
Use Responsive Framework to automatically scale your UI.
18-
19-
> **ResponsiveBreakpoint.autoScale(600);**
9+
The Responsive Framework includes widgets that help developers build responsive apps for mobile, desktop, and website layouts.
2010

2111
## Demo
2212

@@ -42,31 +32,113 @@ Import this library into your project:
4232
responsive_framework: ^latest_version
4333
```
4434
45-
Add `ResponsiveWrapper.builder` to your MaterialApp or CupertinoApp.
35+
Add `ResponsiveBreakpoints.builder` to your MaterialApp or CupertinoApp. Define your own breakpoints and labels.
4636
```dart
4737
import 'package:responsive_framework/responsive_framework.dart';
4838
4939
class MyApp extends StatelessWidget {
5040
@override
5141
Widget build(BuildContext context) {
5242
return MaterialApp(
53-
builder: (context, child) => ResponsiveWrapper.builder(
54-
child,
55-
maxWidth: 1200,
56-
minWidth: 480,
57-
defaultScale: true,
58-
breakpoints: [
59-
ResponsiveBreakpoint.resize(480, name: MOBILE),
60-
ResponsiveBreakpoint.autoScale(800, name: TABLET),
61-
ResponsiveBreakpoint.resize(1000, name: DESKTOP),
62-
],
63-
background: Container(color: Color(0xFFF5F5F5))),
43+
builder: (context, child) => ResponsiveBreakpoints.builder(
44+
child: child!,
45+
breakpoints: [
46+
const Breakpoint(start: 0, end: 450, name: MOBILE),
47+
const Breakpoint(start: 451, end: 800, name: TABLET),
48+
const Breakpoint(start: 801, end: 1920, name: DESKTOP),
49+
const Breakpoint(start: 1921, end: double.infinity, name: '4K'),
50+
],
51+
),
6452
initialRoute: "/",
6553
);
6654
}
6755
}
6856
```
69-
That's it!
57+
58+
Use the labels you defined for layouts and values.
59+
60+
```dart
61+
// Example: if the screen is bigger than the Mobile breakpoint, build full width AppBar icons and labels.
62+
if (ResponsiveBreakpoints.of(context).isLargerThan(MOBILE))
63+
FullWidthAppBarItems()
64+
65+
// Booleans
66+
ResponsiveBreakpoints.of(context).isDesktop;
67+
ResponsiveBreakpoints.of(context).isTablet;
68+
ResponsiveBreakpoints.of(context).isMobile;
69+
ResponsiveBreakpoints.of(context).isPhone;
70+
71+
// Conditionals
72+
ResponsiveBreakpoints.of(context).equals(DESKTOP)
73+
ResponsiveBreakpoints.of(context).isLargerThan(MOBILE)
74+
ResponsiveBreakpoints.of(context).isSmallerThan(TABLET)
75+
```
76+
77+
### Customization
78+
You can define your own breakpoint labels and use them in your conditionals.
79+
80+
For example, if we're building a Material 3 Navigation Rail and want to expand the menu to full width once there is enough room, we can add a custom `EXPAND_SIDE_PANEL` breakpoint.
81+
82+
```dart
83+
breakpoints: [
84+
...
85+
const Breakpoint(start: 801, end: 1920, name: DESKTOP),
86+
const Breakpoint(start: 900, end: double.infinity, name: 'EXPAND_SIDE_PANEL') <- Custom behavior Range.
87+
const Breakpoint(start: 1921, end: double.infinity, name: '4K'),
88+
...
89+
]
90+
```
91+
92+
Then, in our code, set the value based on if the breakpoint is active.
93+
94+
> expand: ResponsiveBreakpoints.of(context).equals('EXPAND_SIDE_PANEL')
95+
96+
### Responsive Framework Widgets
97+
The ResponsiveFramework includes a few custom widgets that to supplement Flutter's responsive capabilities. They are showcased in the demo projects.
98+
99+
- *[ResponsiveValue](https://github.com/Codelessly/ResponsiveFramework/blob/master/lib/responsive_value.dart)*
100+
- *[ResponsiveRowColumn](https://github.com/Codelessly/ResponsiveFramework/blob/master/lib/responsive_row_column.dart)*
101+
- *[ResponsiveGridView](https://github.com/Codelessly/ResponsiveFramework/blob/master/lib/responsive_grid.dart)*
102+
- *[ResponsiveScaledBox](https://github.com/Codelessly/ResponsiveFramework/blob/master/lib/responsive_scaled_box.dart)*
103+
- *[MaxWidthBox](https://github.com/Codelessly/ResponsiveFramework/blob/master/lib/max_width_box.dart)*
104+
105+
106+
## Legacy ReadMe (v0.2.0 and below)
107+
108+
### ResponsiveWrapper Migration
109+
The legacy ResponsiveWrapper combined multiple features into one widget. This made it difficult to use at times when custom behavior was required. The updated V1 implementation separates each feature into its own widget and is now more modular.
110+
111+
Responsive Framework v1 introduces some new widgets:
112+
113+
- ResponsiveScaledBox
114+
- MaxWidthBox
115+
- ConditionalRouteWidget
116+
117+
#### ResponsiveScaledBox
118+
> ResponsiveScaledBox(width: width, child: child);
119+
120+
Replaces the core AutoScale functionality of ResponsiveWrapper. ResponsiveScaledBox renders the `child` widget with the specified `width`.
121+
122+
This widget simply wraps the Flutter `FittedBox` widget with a `LayoutBuilder` and `MediaQuery`. Use a `ResponsiveScaledBox` instead of a `FittedBox` if the layout being wrapped is full screen as the widget helps calculate scaled `MediaQueryData`.
123+
124+
#### MaxWidthBox
125+
> MaxWidthBox(maxWidth: maxWidth, background: background, child: child);
126+
127+
Limits the `child` widget to the `maxWidth` and paints an optional `background` behind the widget. This widget is helpful for limiting the content width on large desktop displays and creating gutters on the left and right side of the page.
128+
129+
130+
### The remainder of the legacy ReadMe is preserved below as the concepts are useful and supported by the new widgets. ResponsiveWrapper has been deprecated and removed.
131+
132+
### The Problem
133+
Supporting multiple display sizes often means recreating the same layout multiple times. Under the traditional _Bootstrap_ approach, building responsive UI is time consuming, frustrating and repetitive. Furthermore, getting everything pixel perfect is near impossible and simple edits take hours.
134+
135+
![Screenshots](packages/Bad%20Viewport%20Selector%20Animated.gif)
136+
137+
### The Solution
138+
Use Responsive Framework to automatically scale your UI.
139+
140+
> **ResponsiveBreakpoint.autoScale(600);**
141+
70142

71143
## AutoScale
72144

0 commit comments

Comments
 (0)