Member-only story
Double And Triple Dots In Flutter

In flutter, we see double dots and triple dots were used in code. But we actually don’t know what are they, why are they used , what’s the reason of using double and triple dots in flutter and where to use.
Here we go:
Double dots(..) i.e cascade operator
“.. ”is known as cascade notation(allow you to make a sequence of operations on the same object). It allows you to not repeat the same target if you want to call several methods on the same object.This often saves you the step of creating a temporary variable and allows you to write more fluid code.
Normally, we use the below way to define several methods on the same object.
var paint = Paint();
paint.color = Colors.black;
paint.strokeCap = StrokeCap.round;
paint.strokeWidth = 5.0;
But after using “..”, the above code will be written like this:
var paint = Paint()
..color = Colors.black
..strokeCap = StrokeCap.round
..strokeWidth = 5.0;
Triple dots(…) i.e. Spread Operator
“… ”also known as spread operator which provide a concise way to insert multiple values into a collection.You can use this to insert all the elements of a list into another list:
Normally we use .add() or .addAll() to add data to the list like:
var list = [1, 2, 3];
var list2=[];
list2.addAll(list);
After using “…” we will write code like this:
var list = [1, 2, 3];
var list2 = [0, ...list];
So this is all about double and triple dots in flutter and their used case.
For more info buy the book “Make Yourself The Software Developer: Let’s Dive into Flutter & MNCs” buy.
Thanks