Closed friebetill closed 3 years ago
@friebetill Can you check out this article and see if it helps ?
@darshankawar Thanks for your reply.
The article introduces the three (four) sliver widgets:
SliverToBoxAdapter
Useful to display a box widget in a CustomScrollView
. SliverList
(SliverFixedExtentList
)
Useful to arrange multiple box widgets in a column. (SliverFixedExtentList
does the same as SliverList
, except that the children have the same height).SliverGrid
Useful to arrange box widgets in a grid.I can't use any of the three (four) widgets because I have two sliver widgets and want to display them in a column. But SliverToBoxAdapter
, SliverList
and SliverGrid
expect box widget(s).
I think this is a dupe of https://github.com/flutter/flutter/issues/33137 And it looks like there is a package that does this: https://pub.dev/packages/sliver_tools
@friebetill Check out the original issue and follow-up there for updates. You may also check out the plugin listed and see if it serves your purpose. Closing from here for now. If you disagree, write in comments and I'll reopen it. Thanks.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
Use case
I have a
CustomScrollView
with the following structure:MyCustomSliverTitle
extendsStatelessWidget
and in thebuild
method returns aSliverToBoxAdapter
widget, and theMyCustomSliverFixedExtendList
widget extendsStatelessWidget
and in the build method returns aSliverFixedExtentList
widget.How can I implement a single Widget (
MyCustomSliverListWithTitle
) that returns both the custom title and the custom list?I tried to solve this problem in
MyCustomSliverListWithTitle
with the following widgets:CustomScrollView
This worked until I added new items to the list and changed the size of the list. Then this exception was thrown:
When the exception was thrown, this was the stack:
0 RenderSliverFixedExtentBoxAdaptor.performLayout package:flutter/…/rendering/sliver_fixed_extent_list.dart:190
1 RenderObject.layout package:flutter/…/rendering/object.dart:1777
2 RenderViewportBase.layoutChildSequence package:flutter/…/rendering/viewport.dart:507
3 RenderShrinkWrappingViewport._attemptLayout package:flutter/…/rendering/viewport.dart:1904
4 RenderShrinkWrappingViewport.performLayout package:flutter/…/rendering/viewport.dart:1862
5 RenderObject.layout package:flutter/…/rendering/object.dart:1777
6 RenderProxyBoxMixin.performLayout package:flutter/…/rendering/proxy_box.dart:113
7 RenderObject.layout package:flutter/…/rendering/object.dart:1777
8 RenderProxyBoxMixin.performLayout package:flutter/…/rendering/proxy_box.dart:113
9 RenderObject.layout package:flutter/…/rendering/object.dart:1777
...
This leads to this error
A solution would be nice to have, because I am using an MVVM architecture and both
MyCustomSliverTitle
andMyCustomSliverFixedExtendList
access data from theViewModel
. In addition, it also helps with the separations of concerns.The problem description is inspired by this StackOverflow question.
Proposal
Solutions that came to my mind for now:
SliverFixedExtentList
inside the secondCustomScrollChildView
can handle resizing.But maybe there is a solution already and I haven't found it yet.