collection: fixed scrolling when there is no content

This commit is contained in:
Thibault Deckers 2020-03-30 09:06:01 +09:00
parent fc014a6274
commit c8b8d9c897
2 changed files with 7 additions and 5 deletions

View file

@ -6,7 +6,7 @@ class EmptyContent extends StatelessWidget {
Widget build(BuildContext context) {
const color = Color(0xFF607D8B);
return Align(
alignment: const FractionalOffset(.5, .4),
alignment: const FractionalOffset(.5, .3),
child: Column(
mainAxisSize: MainAxisSize.min,
children: const [

View file

@ -50,13 +50,15 @@ class ThumbnailCollection extends StatelessWidget {
final scrollView = CustomScrollView(
key: _scrollableKey,
primary: true,
// workaround to prevent scrolling the app bar away
// when there is no content and we use `SliverFillRemaining`
physics: collection.isEmpty ? const NeverScrollableScrollPhysics() : null,
slivers: [
if (appBar != null) appBar,
if (collection.isEmpty && emptyBuilder != null)
SliverFillViewport(
delegate: SliverChildListDelegate.fixed(
[emptyBuilder(context)],
),
SliverFillRemaining(
child: emptyBuilder(context),
hasScrollBody: false,
),
...sectionKeys.map((sectionKey) => SectionSliver(
collection: collection,