0

I saw this code, but found no explanation for what "..." means.

return ListView(
              children: <Widget>[
                if (bookCards != null) ...bookCards,
              ],
            );

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
cyberpVnk
  • 109
  • 1
  • 1
  • 2

1 Answers1

2

It is called Spread Operator. It was included in dart from Dart 2.3.

How to use it? Consider the below as the basic example of how to use Spread Operator (...) in dart.

var var1 = [0,1,2,3,4];
var var2 = [6,7,8,9];
var var3 = [...var1,5,...var2];

print(var3);

It prints [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Maz341
  • 2,232
  • 15
  • 20