# Cascade notation

{% embed url="<https://youtu.be/eHFVBAfMBgU>" %}

{% tabs %}
{% tab title="First Tab" %}

```dart
void main() {
  var employee1 = Employee();

//   employee1.id = 1;

//   employee1.firstname = "John";

//   employee1.lastname = "Doe";

//   employee1.position = "CTO";

  employee1
    ..id = 1
    ..firstname = "John"
    ..lastname = "Doe"
    ..position = "CTO";

  print(employee1.toString());
}

class Employee {
  int id;

  String firstname;

  String lastname;

  String position;

  @override
  String toString() {
    return "id : $id , firstname : $firstname , lastname : $lastname, position : $position";
  }
}


```

{% endtab %}

{% tab title="Second Tab" %}

```dart
void main() {
  // Cascade Notation

  var calculator1 = Calculator(3);

//   calculator1.add(12);
//   calculator1.subtract(12);
//   calculator1.add(5);
//   calculator1.subtract(9);

  calculator1
    ..add(12)
    ..subtract(12)
    ..add(5)
    ..subtract(9);

  print(calculator1.result());
}

class Calculator {
  int output = 0;

  Calculator(int startValue) {
    this.output = startValue;
  }

  void add(int val) {
    this.output += val;
  }

  void subtract(int val) {
    this.output -= val;
  }

  int result() {
    return this.output;
  }
}



```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Using the cascade notation with methods is also known as **method chaining** . \
You are consecutively calling methods i.e. chaining methods&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eece.gitbook.io/mist-innovation-club-flutter-course-1/dart-fundamentals-1/miscellaneous-concepts/cascade-notation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
