@@ -17,19 +17,19 @@ flutter run --release
1717
1818## AdaptiveScaffold
1919
20- AdaptiveScaffold implements the basic visual layout structure for Material
20+ ` AdaptiveScaffold ` implements the basic visual layout structure for Material
2121Design 3 that adapts to a variety of screens. It provides a preset of layout,
2222including positions and animations, by handling macro changes in navigational
2323elements and bodies based on the current features of the screen, namely screen
2424width and platform. For example, the navigational elements would be a
25- BottomNavigationBar on a small mobile device and a NavigationRail on larger
25+ ` BottomNavigationBar ` on a small mobile device and a ` NavigationRail ` on larger
2626devices. The body is the primary screen that takes up the space left by the
2727navigational elements. The secondaryBody acts as an option to split the space
2828between two panes for purposes such as having a detail view. There is some
2929automatic functionality with foldables to handle the split between panels
30- properly. AdaptiveScaffold is much simpler to use but is not the best if you
30+ properly. ` AdaptiveScaffold ` is much simpler to use but is not the best if you
3131would like high customizability. Apps that would like more refined layout and/or
32- animation should use AdaptiveLayout.
32+ animation should use ` AdaptiveLayout ` .
3333
3434### Example Usage
3535
@@ -52,10 +52,12 @@ Widget build(BuildContext context) {
5252 // An option to override the default transition duration.
5353 transitionDuration: Duration(milliseconds: _transitionDuration),
5454 // An option to override the default breakpoints used for small, medium,
55- // and large.
56- smallBreakpoint: const WidthPlatformBreakpoint(end: 700),
57- mediumBreakpoint: const WidthPlatformBreakpoint(begin: 700, end: 1000),
58- largeBreakpoint: const WidthPlatformBreakpoint(begin: 1000),
55+ // mediumLarge, large, and extraLarge.
56+ smallBreakpoint: const Breakpoint(endWidth: 700),
57+ mediumBreakpoint: const Breakpoint(beginWidth: 700, endWidth: 1000),
58+ mediumLargeBreakpoint: const Breakpoint(beginWidth: 1000, endWidth: 1200),
59+ largeBreakpoint: const Breakpoint(beginWidth: 1200, endWidth: 1600),
60+ extraLargeBreakpoint: const Breakpoint(beginWidth: 1600),
5961 useDrawer: false,
6062 selectedIndex: _selectedTab,
6163 onSelectedIndexChange: (int index) {
@@ -90,19 +92,33 @@ Widget build(BuildContext context) {
9092 label: 'Inbox',
9193 ),
9294 ],
93- body: (_) => GridView.count(crossAxisCount: 2, children: children),
9495 smallBody: (_) => ListView.builder(
9596 itemCount: children.length,
9697 itemBuilder: (_, int idx) => children[idx],
9798 ),
99+ body: (_) => GridView.count(crossAxisCount: 2, children: children),
100+ mediumLargeBody: (_) =>
101+ GridView.count(crossAxisCount: 3, children: children),
102+ largeBody: (_) => GridView.count(crossAxisCount: 4, children: children),
103+ extraLargeBody: (_) =>
104+ GridView.count(crossAxisCount: 5, children: children),
98105 // Define a default secondaryBody.
99- secondaryBody: (_) => Container(
100- color: const Color.fromARGB(255, 234, 158, 192),
101- ),
102106 // Override the default secondaryBody during the smallBreakpoint to be
103107 // empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly
104108 // overridden.
105109 smallSecondaryBody: AdaptiveScaffold.emptyBuilder,
110+ secondaryBody: (_) => Container(
111+ color: const Color.fromARGB(255, 234, 158, 192),
112+ ),
113+ mediumLargeSecondaryBody: (_) => Container(
114+ color: const Color.fromARGB(255, 234, 158, 192),
115+ ),
116+ largeSecondaryBody: (_) => Container(
117+ color: const Color.fromARGB(255, 234, 158, 192),
118+ ),
119+ extraLargeSecondaryBody: (_) => Container(
120+ color: const Color.fromARGB(255, 234, 158, 192),
121+ ),
106122 );
107123}
108124```
@@ -115,16 +131,16 @@ customizability at a cost of more lines of code.
115131### AdaptiveLayout
116132
117133![ "AdaptiveLayout's Assigned Slots Displayed on Screen"] ( example/demo_files/screenSlots.png )
118- AdaptiveLayout is the top-level widget class that arranges the layout of the
134+ ` AdaptiveLayout ` is the top-level widget class that arranges the layout of the
119135slots and their animation, similar to Scaffold. It takes in several LayoutSlots
120- and returns an appropriate layout based on the diagram above. AdaptiveScaffold
121- is built upon AdaptiveLayout internally but abstracts some of the complexity
136+ and returns an appropriate layout based on the diagram above. ` AdaptiveScaffold `
137+ is built upon ` AdaptiveLayout ` internally but abstracts some of the complexity
122138with presets based on the Material 3 Design specification.
123139
124140### SlotLayout
125141
126- SlotLayout handles the adaptivity or the changes between widgets at certain
127- Breakpoints. It also holds the logic for animating between breakpoints. It takes
142+ ` SlotLayout ` handles the adaptivity or the changes between widgets at certain
143+ ` Breakpoints ` . It also holds the logic for animating between breakpoints. It takes
128144SlotLayoutConfigs mapped to Breakpoints in a config and displays a widget based
129145on that information.
130146
@@ -169,6 +185,39 @@ return AdaptiveLayout(
169185 unSelectedLabelTextStyle: navRailTheme.unselectedLabelTextStyle,
170186 ),
171187 ),
188+ Breakpoints.mediumLarge: SlotLayout.from(
189+ key: const Key('Primary Navigation MediumLarge'),
190+ inAnimation: AdaptiveScaffold.leftOutIn,
191+ builder: (_) => AdaptiveScaffold.standardNavigationRail(
192+ selectedIndex: selectedNavigation,
193+ onDestinationSelected: (int newIndex) {
194+ setState(() {
195+ selectedNavigation = newIndex;
196+ });
197+ },
198+ extended: true,
199+ leading: Row(
200+ mainAxisAlignment: MainAxisAlignment.spaceAround,
201+ children: <Widget>[
202+ Text(
203+ 'REPLY',
204+ style: headerColor,
205+ ),
206+ const Icon(Icons.menu_open)
207+ ],
208+ ),
209+ destinations: destinations
210+ .map((NavigationDestination destination) =>
211+ AdaptiveScaffold.toRailDestination(destination))
212+ .toList(),
213+ trailing: trailingNavRail,
214+ backgroundColor: navRailTheme.backgroundColor,
215+ selectedIconTheme: navRailTheme.selectedIconTheme,
216+ unselectedIconTheme: navRailTheme.unselectedIconTheme,
217+ selectedLabelTextStyle: navRailTheme.selectedLabelTextStyle,
218+ unSelectedLabelTextStyle: navRailTheme.unselectedLabelTextStyle,
219+ ),
220+ ),
172221 Breakpoints.large: SlotLayout.from(
173222 key: const Key('Primary Navigation Large'),
174223 inAnimation: AdaptiveScaffold.leftOutIn,
@@ -180,14 +229,47 @@ return AdaptiveLayout(
180229 });
181230 },
182231 extended: true,
183- leading: const Row(
232+ leading: Row(
233+ mainAxisAlignment: MainAxisAlignment.spaceAround,
234+ children: <Widget>[
235+ Text(
236+ 'REPLY',
237+ style: headerColor,
238+ ),
239+ const Icon(Icons.menu_open)
240+ ],
241+ ),
242+ destinations: destinations
243+ .map((NavigationDestination destination) =>
244+ AdaptiveScaffold.toRailDestination(destination))
245+ .toList(),
246+ trailing: trailingNavRail,
247+ backgroundColor: navRailTheme.backgroundColor,
248+ selectedIconTheme: navRailTheme.selectedIconTheme,
249+ unselectedIconTheme: navRailTheme.unselectedIconTheme,
250+ selectedLabelTextStyle: navRailTheme.selectedLabelTextStyle,
251+ unSelectedLabelTextStyle: navRailTheme.unselectedLabelTextStyle,
252+ ),
253+ ),
254+ Breakpoints.extraLarge: SlotLayout.from(
255+ key: const Key('Primary Navigation ExtraLarge'),
256+ inAnimation: AdaptiveScaffold.leftOutIn,
257+ builder: (_) => AdaptiveScaffold.standardNavigationRail(
258+ selectedIndex: selectedNavigation,
259+ onDestinationSelected: (int newIndex) {
260+ setState(() {
261+ selectedNavigation = newIndex;
262+ });
263+ },
264+ extended: true,
265+ leading: Row(
184266 mainAxisAlignment: MainAxisAlignment.spaceAround,
185267 children: <Widget>[
186268 Text(
187269 'REPLY',
188- style: TextStyle(color: Color.fromARGB(255, 255, 201, 197)) ,
270+ style: headerColor ,
189271 ),
190- Icon(Icons.menu_open)
272+ const Icon(Icons.menu_open)
191273 ],
192274 ),
193275 destinations: destinations
@@ -215,11 +297,26 @@ return AdaptiveLayout(
215297 itemBuilder: (BuildContext context, int index) => children[index],
216298 ),
217299 ),
218- Breakpoints.mediumAndUp : SlotLayout.from(
300+ Breakpoints.medium : SlotLayout.from(
219301 key: const Key('Body Medium'),
220302 builder: (_) =>
221303 GridView.count(crossAxisCount: 2, children: children),
222- )
304+ ),
305+ Breakpoints.mediumLarge: SlotLayout.from(
306+ key: const Key('Body MediumLarge'),
307+ builder: (_) =>
308+ GridView.count(crossAxisCount: 3, children: children),
309+ ),
310+ Breakpoints.large: SlotLayout.from(
311+ key: const Key('Body Large'),
312+ builder: (_) =>
313+ GridView.count(crossAxisCount: 4, children: children),
314+ ),
315+ Breakpoints.extraLarge: SlotLayout.from(
316+ key: const Key('Body ExtraLarge'),
317+ builder: (_) =>
318+ GridView.count(crossAxisCount: 5, children: children),
319+ ),
223320 },
224321 ),
225322 // BottomNavigation is only active in small views defined as under 600 dp
0 commit comments