Remember those days in different languages when you are utilising an object and you need to call methods with that object multiple times. Cascade Notation is denoted using a pair of dots(..), pseudo code will clear things a bit more.
Object..method1()..method2()
Now object can be anything like List, Maps etc. Let's look at the sample code then things will become more clear.
var f1 = {1: 'Apple', 2: 'Orange'};
var f2 = {3: 'Banana'};
var f3 = {4: 'Mango'};
var fruit = {}..addAll(f1)..addAll(f2)..addAll(f3);
print('Merging maps using cascade notation: $fruit');
In the code above, we see cascade notation of dart in action. It is allowing us to perform sequence of operations with repeating code, as a result our code is compact and eye pleasing. I hope you enjoyed this little episode of Dart till next time take care and see you guys soon 😊
Top comments (0)