@@ -119,6 +119,65 @@ class ExampleHorizontal extends StatelessWidget {
119
119
}
120
120
}
121
121
122
+ /// An experimental example approximating the Zulip message list.
123
+ class ExampleVerticalDouble extends StatelessWidget {
124
+ const ExampleVerticalDouble ({
125
+ super .key,
126
+ required this .title,
127
+ // this.reverse = false,
128
+ // this.headerDirection = AxisDirection.down,
129
+ }); // : assert(axisDirectionToAxis(headerDirection) == Axis.vertical);
130
+
131
+ final String title;
132
+ // final bool reverse;
133
+ // final AxisDirection headerDirection;
134
+
135
+ @override
136
+ Widget build (BuildContext context) {
137
+ const centerSliverKey = ValueKey ('center sliver' );
138
+ const numSections = 100 ;
139
+ const numBottomSections = 2 ;
140
+ const numPerSection = 10 ;
141
+ return Scaffold (
142
+ appBar: AppBar (title: Text (title)),
143
+ body: CustomScrollView (
144
+ semanticChildCount: numSections,
145
+ anchor: 0.5 ,
146
+ center: centerSliverKey,
147
+ slivers: [
148
+ SliverStickyHeaderList (
149
+ headerPlacement: HeaderPlacement .scrollingStart,
150
+ delegate: SliverChildBuilderDelegate (
151
+ childCount: numSections - numBottomSections,
152
+ (context, i) {
153
+ final ii = i + numBottomSections;
154
+ return StickyHeaderItem (
155
+ header: WideHeader (i: ii),
156
+ child: Column (
157
+ children: List .generate (numPerSection + 1 , (j) {
158
+ if (j == 0 ) return WideHeader (i: ii);
159
+ return WideItem (i: ii, j: j- 1 );
160
+ })));
161
+ })),
162
+ SliverStickyHeaderList (
163
+ key: centerSliverKey,
164
+ headerPlacement: HeaderPlacement .scrollingStart,
165
+ delegate: SliverChildBuilderDelegate (
166
+ childCount: numBottomSections,
167
+ (context, i) {
168
+ final ii = numBottomSections - 1 - i;
169
+ return StickyHeaderItem (
170
+ header: WideHeader (i: ii),
171
+ child: Column (
172
+ children: List .generate (numPerSection + 1 , (j) {
173
+ if (j == 0 ) return WideHeader (i: ii);
174
+ return WideItem (i: ii, j: j- 1 );
175
+ })));
176
+ })),
177
+ ]));
178
+ }
179
+ }
180
+
122
181
////////////////////////////////////////////////////////////////////////////
123
182
//
124
183
// That's it!
@@ -257,6 +316,11 @@ class MainPage extends StatelessWidget {
257
316
reverse: true ,
258
317
headerDirection: AxisDirection .left),
259
318
];
319
+ final otherItems = [
320
+ _buildButton (context,
321
+ title: 'Double slivers' ,
322
+ page: ExampleVerticalDouble (title: 'Double slivers' )),
323
+ ];
260
324
return Scaffold (
261
325
appBar: AppBar (title: const Text ('Sticky Headers example' )),
262
326
body: CustomScrollView (slivers: [
@@ -284,6 +348,18 @@ class MainPage extends StatelessWidget {
284
348
childAspectRatio: 2 ,
285
349
crossAxisCount: 2 ,
286
350
children: horizontalItems)),
351
+ SliverToBoxAdapter (
352
+ child: Padding (
353
+ padding: const EdgeInsets .only (top: 24 ),
354
+ child: Center (
355
+ child: Text ("Other examples" ,
356
+ style: Theme .of (context).textTheme.headlineMedium)))),
357
+ SliverPadding (
358
+ padding: const EdgeInsets .symmetric (vertical: 8 , horizontal: 16 ),
359
+ sliver: SliverGrid .count (
360
+ childAspectRatio: 2 ,
361
+ crossAxisCount: 2 ,
362
+ children: otherItems)),
287
363
]));
288
364
}
289
365
@@ -304,7 +380,14 @@ class MainPage extends StatelessWidget {
304
380
title: title, reverse: reverse, headerDirection: headerDirection);
305
381
break ;
306
382
}
383
+ return _buildButton (context, title: title, page: page);
384
+ }
307
385
386
+ Widget _buildButton (BuildContext context, {
387
+ bool primary = false ,
388
+ required String title,
389
+ required Widget page,
390
+ }) {
308
391
var label = Text (title,
309
392
textAlign: TextAlign .center,
310
393
style: TextStyle (
0 commit comments