Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

Dart Cascade Notation

Cascade notation, denoted by the .. operator in Dart, allows you to perform a sequence of operations on the same object without having to repeat its name. It's particularly useful when you need to invoke multiple methods or setters on an object consecutively.



Basic Syntax :

object..method1()
..method2()
..property1 = value1
..property2 = value2;

Example

class Person {
String name;
int age;
Person(this.name, this.age);
void introduceYourself() {
print("Hello, my name is $name and I'm $age years old.");
}
}
void main() {
var person = Person("Alice", 30);
// Without cascade notation
person.name = "Bob";
person.age = 25;
person.introduceYourself();
// With cascade notation
person
..name = "Charlie"
..age = 40
..introduceYourself();
}




Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java