What does ...
mean in this code?
The code is:
if (state.isSubmitting) ...[
const SizedBox(height: 8),
const LinearProgressIndicator(value: null),
]
CodePudding user response:
In Dart
(...) Tripple dot is called as spread operator
which is basically introduced in Dart 2.3
.
Well, spread operator
provides an easy way to insert multiple-element into a collection
var numbers = [1, 2, 3];
var numbers2 = [0, ...list];
print(numbers2);
And the spread operator
is also a null aware one, for example
var numbers;
var numbers2 = [0, ...?list];
print(numbers2);
for more and conscious explanation you can refer to this link Dart spread operstor
CodePudding user response:
According to Dart documentation, the Spread Operator(...) provides a concise way to insert multiple values into a collection. For instance, let's say there is a List:
var list = [1, 2, 3];
and you want to add this list to another list, you use spread operator
var anotherList = [0, 1, ...list];