Ahmed Hussein
05fbe0ed1b
Add SliverGrid.list convenience constructor ( #173925 )
...
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 : #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>
2025-08-29 21:05:42 +00:00
..
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-30 18:40:09 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-08-14 18:06:57 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-04-09 03:31:31 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-09 21:22:48 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-01-25 05:50:26 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-08 18:47:17 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-11 15:27:56 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-22 22:38:17 +00:00
2025-08-12 22:07:18 +00:00
2025-08-08 18:47:17 +00:00
2024-12-19 20:06:21 +00:00
2025-08-14 19:53:20 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-15 22:40:14 +00:00
2024-12-19 20:06:21 +00:00
2025-06-09 15:01:53 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-08-14 18:06:57 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-06-25 19:12:23 +00:00
2025-08-14 19:53:20 +00:00
2025-07-07 17:58:32 +00:00
2025-07-30 18:40:09 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-30 18:31:41 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-14 19:53:20 +00:00
2025-08-15 22:40:14 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-29 01:11:25 +00:00
2025-08-04 22:32:22 +00:00
2025-08-27 22:17:05 +00:00
2025-07-07 17:58:32 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-27 22:17:05 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-07 19:30:24 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-01-14 05:13:41 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-14 22:49:04 +00:00
2025-07-14 22:49:04 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2025-03-05 17:41:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-31 16:06:07 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-05-29 17:30:32 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-05-27 19:39:24 +00:00
2025-07-07 17:58:32 +00:00
2025-08-08 18:47:17 +00:00
2024-12-19 20:06:21 +00:00
2025-02-06 03:08:23 +00:00
2025-02-06 03:08:23 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-02-06 03:08:23 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-02-06 03:08:23 +00:00
2025-06-12 21:26:00 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-04-29 20:58:29 +00:00
2025-04-29 20:58:29 +00:00
2025-04-29 20:58:29 +00:00
2025-04-29 20:58:29 +00:00
2025-04-29 20:58:29 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-08-27 08:17:40 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-08-27 08:17:40 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 22:32:22 +00:00
2025-08-04 22:32:22 +00:00
2025-08-15 22:40:14 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2025-05-23 00:02:01 +00:00
2025-08-29 21:05:42 +00:00
2025-08-04 22:32:22 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-08-27 22:17:05 +00:00
2025-07-07 17:58:32 +00:00
2025-08-26 05:11:45 +00:00
2025-07-07 17:58:32 +00:00
2025-07-08 17:18:58 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-23 23:56:48 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-08-14 19:53:20 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-02-05 20:51:29 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2025-07-07 17:58:32 +00:00
2024-12-19 20:06:21 +00:00
2025-08-04 17:54:53 +00:00
2025-07-07 17:58:32 +00:00