Cascade Notation Method Chaining on Steroids

Cascades Notation(...) allows chaining a sequence of operations on the same object. Besides, fields (data-members) can be accessed using the same.


class Person {
  String name;
  int age:
  Person(this.name, this.age);
  void data() => print("$name is $age years old.");
}

//Without Cascade Notation
Person person = Person("Richard", 50);
person.age = 22;
person.name += " Parker";
person.data():

//Cascade Notation with Object of Person
Person("Jian", 21)
..age = 22
..name += " Yang"
..data();

//Cascade Notation with List
<String>["Natasha", "Steve", "Peter", "Tony"]
..sort()
..forEach((name) => print("\n$name"));