Skip to content

Commit a1cd62a

Browse files
committed
sticky_header example: Add back-to-back list with headers at top
This example demonstrates a bug we'll shortly fix: an overflowing sliver getting painted before the sliver it's meant to overflow onto.
1 parent e524e6b commit a1cd62a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/example/sticky_header.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ class ExampleVerticalDouble extends StatelessWidget {
126126
required this.title,
127127
// this.reverse = false,
128128
required this.headerPlacement,
129+
required this.topSliverGrowsUpward,
129130
});
130131

131132
final String title;
132133
// final bool reverse;
133134
final HeaderPlacement headerPlacement;
135+
final bool topSliverGrowsUpward;
134136

135137
@override
136138
Widget build(BuildContext context) {
@@ -144,14 +146,9 @@ class ExampleVerticalDouble extends StatelessWidget {
144146
HeaderPlacement.scrollingEnd => true,
145147
};
146148

147-
// Choose the "center" sliver so that the sliver which might need to paint
148-
// a header overflowing the other header is the sliver that paints last.
149-
final centerKey = headerAtBottom ?
149+
final centerKey = topSliverGrowsUpward ?
150150
const ValueKey('bottom') : const ValueKey('top');
151151

152-
// This is a side effect of our choice of centerKey.
153-
final topSliverGrowsUpward = headerAtBottom;
154-
155152
return Scaffold(
156153
appBar: AppBar(title: Text(title)),
157154
body: CustomScrollView(
@@ -345,11 +342,19 @@ class MainPage extends StatelessWidget {
345342
title: 'Double slivers, headers at top',
346343
page: ExampleVerticalDouble(
347344
title: 'Double slivers, headers at top',
345+
topSliverGrowsUpward: false,
346+
headerPlacement: HeaderPlacement.scrollingStart)),
347+
_buildButton(context,
348+
title: 'Split slivers, headers at top',
349+
page: ExampleVerticalDouble(
350+
title: 'Split slivers, headers at top',
351+
topSliverGrowsUpward: true,
348352
headerPlacement: HeaderPlacement.scrollingStart)),
349353
_buildButton(context,
350-
title: 'Double slivers, headers at bottom',
354+
title: 'Split slivers, headers at bottom',
351355
page: ExampleVerticalDouble(
352-
title: 'Double slivers, headers at bottom',
356+
title: 'Split slivers, headers at bottom',
357+
topSliverGrowsUpward: true,
353358
headerPlacement: HeaderPlacement.scrollingEnd)),
354359
];
355360
return Scaffold(

0 commit comments

Comments
 (0)