You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a new `SliverGrid.list` convenience constructor that
accepts a `List<Widget> children` parameter, providing a cleaner API
compared to manually creating `SliverChildListDelegate`.
## What was added
The constructor uses `SliverChildListDelegate` internally and follows
the same pattern as existing convenience constructors like
`SliverGrid.count` and `SliverGrid.extent`. This addresses the use case
where developers want to create sliver grids with predefined widget
lists without the verbosity of manually constructing the delegate.
## Before/After comparison
**Before:**
```dart
SliverGrid(
gridDelegate: gridDelegate,
delegate: SliverChildListDelegate([widget1, widget2, widget3]),
)
```
**After:**
```dart
SliverGrid.list(
gridDelegate: gridDelegate,
children: [widget1, widget2, widget3],
)
```
## Implementation details
- Added `SliverGrid.list` constructor in
`packages/flutter/lib/src/widgets/sliver.dart`
- Constructor accepts `List<Widget> children` and all necessary delegate
configuration parameters
- Uses `SliverChildListDelegate` internally for consistent behavior
- Added comprehensive test coverage in
`packages/flutter/test/widgets/slivers_test.dart`
## Issue addressed
Fixes: flutter#173018
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
---------
Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
0 commit comments