Closed giantss closed 1 year ago
@giantss you can add margin and backgroundColor in Sliver widget, you need sliver_tools package for get widget SliverStack. Example:
SliverStack(
insetOnOverlap: false, // defaults to false
children: <Widget>[
// add background color
SliverPositioned.fill(
child: Container(
decoration: BoxDecoration(
color: Colors.amber,
),
),
),
SliverPadding(
// add margin
padding: EdgeInsets.all(20),
sliver: SliverGrid()
),
],
);
Thanks for your input @farhanfadila1717. Hi @giantss. Thanks for proposing this! Can you try out https://github.com/flutter/flutter/issues/134122#issuecomment-1708381799 to see if it suits your use case?
Thanks @farhanfadila1717.
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.
Is there an existing issue for this?
Use case
When I used
CustomScrollView
SliverGrid
, I found that the background color and margins could not be set separately for SliverGrid. I think this is a very common function, and I found that many developers have encountered similar problems. May I ask if the official plans to add relevant attributes?Proposal
I have used CustomScrollView to realize almost all the effects in the picture above, but SliverGrid cannot set the background color and margins. I have tried various methods and finally failed to achieve it, so I had to give up this component in the end.