-
Notifications
You must be signed in to change notification settings - Fork 29.7k
WIP: SliverGroup #33138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: SliverGroup #33138
Conversation
|
It is not super-clear to me what the use case for such a sliver is. Can you elaborate (and possibly also update the documentation)? Why not throw all those slivers in a CustomScrollView? |
|
@goderbauer I've added an example to the documentation. In the example the purpose it not to duplicate the same padding for every sliver. While for padding that would still be possible (but bad), for other cases it isn't: I've made a Another kind of use cases is creating abstractions. Let's say I want to make a widget that is composed of a heading and a class ListItemGroup extends StatelessWidget {
Widget build(BuildContext context) =>
SliverGroup(
slivers: [
SliverToBoxAdapter(child: heading),
SliverList(items),
);
}which is used like this: CustomScrollView(
slivers: [
SliverAppBar(...),
ListItemGroup(...),
ListItemGroup(...),
],
); |
|
That does sound like a valid use case. This could also live as an external package on pub, though. Is there any reason you feel like this belong in the framework? |
|
It felt fundamental enough to be part of the framework, not very different from |
|
In those cases it may be a good idea to implement them in an external package first. This would allow for fast iterations. When we add something to the framework we have to be sure that it has a reasonable stable API. If the package turns out to be popular, we can always pull it into the framework... |
|
Ok, sounds fine.
…On Wed, 12 Jun 2019 at 23:51, Michael Goderbauer ***@***.***> wrote:
In those cases it may be a good idea to implement them in an external
package first. This would allow for fast iterations. When we add something
to the framework we have to be sure that it has a reasonable stable API. If
the package turns out to be popular, we can always pull it into the
framework...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33138?email_source=notifications&email_token=ABCADAGURZKPEFLQWCRPSEDP2FVXHA5CNFSM4HONTB2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXR4WTA#issuecomment-501467980>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCADADMN3W5D4ZJLCVAHZTP2FVXHANCNFSM4HONTB2A>
.
|
|
I tested this a few months ago during review. There were some cases where it broke, but I've incorporated bits of it into the larger project of Sliver[Flex, Group, Expanded, Spacer]. I should have a PR open for discussion & feedback soon. |
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Clicked comment & re-open instead of just comment. 😅 |
|
@spkersten do you cover for horizontal |
|
@abdulghani I think a widget that groups slivers along the cross-axis direction would not be too hard to make; certainly easier than along the main-axis as I tried here. I might give it a try. I've been meaning to open source several missing sliver widgets, but I got a bit discouraged so it didn't materialise yet. |
|
Hello @spkersten, I have a project where a SliverGroup is quite necessary. The page has a lot of different sections and wrapping all inside a StatefulWidget sounds a terrible idea. I have been using this as my custom SliverGroup. But I wonder if you think your solution is usable for a stable project. It would be very valuable to use, I think it is the most important sliver missing. class SliverSection extends StatelessWidget {
final List<Widget> slivers;
const SliverSection({Key key, this.slivers}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverToBoxAdapter(
child: ShrinkWrappingViewport(
offset: ViewportOffset.zero(),
slivers: slivers,
),
);
}
}``` |
|
@jamesblasco We are using it quite extensively (for the modularisation reason you mention) in two of our released app. If you are putting simple slivers in it (lists, grids, slivertoboxadapters) it should work fine; fancier slivers (fill remaining, persistent header, special custom ones) might not work correctly in the group as that hasn't been tested to the same extent. |
|
Thank you!! Perfect for the moment I am not using anything fancier inside. |
@spkersten – sorry if I've missed it or misunderstood, is your sliver package available on pub.dev? |
|
@scopendo I never got around making a package. However, there is sliver_tools that contains a widget that seems to offer the same functionality. |
|
If you give me your permission @spkersten to use this code, I would be happy to use it with some modifications to build a package out of it, also adapt it for null-safety and add tests. I have been using it for some projects and I find it super useful |
Description
A widget like Column but for Slivers.
Related Issues
#33137
Tests
TODO: not entirely clear how to properly test the big parameter space of slivers.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?