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) { Widget build(BuildContext context) {
const color = Color(0xFF607D8B); const color = Color(0xFF607D8B);
return Align( return Align(
alignment: const FractionalOffset(.5, .4), alignment: const FractionalOffset(.5, .3),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: const [ children: const [

View file

@ -50,13 +50,15 @@ class ThumbnailCollection extends StatelessWidget {
final scrollView = CustomScrollView( final scrollView = CustomScrollView(
key: _scrollableKey, key: _scrollableKey,
primary: true, 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: [ slivers: [
if (appBar != null) appBar, if (appBar != null) appBar,
if (collection.isEmpty && emptyBuilder != null) if (collection.isEmpty && emptyBuilder != null)
SliverFillViewport( SliverFillRemaining(
delegate: SliverChildListDelegate.fixed( child: emptyBuilder(context),
[emptyBuilder(context)], hasScrollBody: false,
),
), ),
...sectionKeys.map((sectionKey) => SectionSliver( ...sectionKeys.map((sectionKey) => SectionSliver(
collection: collection, collection: collection,