Dart Collections: Dart Spread Operations

Jinali GhoghariJinali Ghoghari
1 min read

In Dart, spread operations allow you to easily combine or create collections by spreading the elements of another collection. There are two types of spread operations: spread (...) and null-aware spread (...?).

Spread ( . . .) Operations

List:

Set:

Maps:

Null-aware Spread (...?) Operation

The null-aware spread operator (...?) is used to spread elements only if the source collection is not null.

List:

Set:

Maps:

Spread operations are useful for creating new collections, combining existing ones, and handling cases where collections might be null. They provide a concise and readable way to manipulate collections in Dart.

0
Subscribe to my newsletter

Read articles from Jinali Ghoghari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jinali Ghoghari
Jinali Ghoghari