-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Labels
📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterdesign docTracks a design discussion documentTracks a design discussion documentf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
Related:
Use case
Currently when trying to implement tree UIs (for example: comments section with nested comments - see Instagram's comments for reference) there is no way to do it but to flatten the list and use one SliverList to show the data in the UI.
Proposal
Add a way to add a SliverList inside of a SliverList.
This will allow the CustomListView to scroll with all the data while also perform nicely with all the Slivers benefits.
In my use case, this is critical in SliverAnimatedList.
If you have any other solutions I will be happy to discuss.
Solutions I tried
- Using a ListView.Builder inside the SliverList builder function with shrinkWrap: true. - Poor Performance
- As pointed above - Normalizing the nested list with the list.expand function and using this list as the data source. - Poor Developer Experience - because everytime new data arrives we need to manage the flattened list which is not ideal.
Code example
CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
final data = widget.comments[index];
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == 0) {
return CommentWidget(data);
} else {
return CommentWidget(
data.comments[index - 1],
isNested: true);
}
},
childCount: data.comments.length + 1,
),
);
},
childCount: widget.comments.length,
),
),
]
)tristan-vrt, Phat0M, Maatteogekko, ashilkn, koodimetsa and 8 more
Metadata
Metadata
Assignees
Labels
📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterdesign docTracks a design discussion documentTracks a design discussion documentf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight