Skip to main content

Command Palette

Search for a command to run...

2/ 100DaysOfFlutter: Dart Control Startment/ Ternary Operator.

Updated
2 min read
2/ 100DaysOfFlutter: Dart Control Startment/ Ternary Operator.
A

Self taught programmer

Dart Control Startment

Controlling the flow of your application is a key part of any programme, controlling flow means handling, what your programme can perform, do, and act.

(Decision making) 🧠

if/else

if (condition) {
  // do something
} else {
  // do something else
}

Switch

switch statement means when the value of the expression is equal to one of the case values, it will do that action.

switch (expression) {
  case value1:
    // do something
    break;
  case value2:
    // do something
    break;
  default:
    // do something
}

(Loop/ Iteration) 🤹🏾

While Loop

which means until the condition is true the loop with continuing the task, don't over-complicate the code,

while (condition) {
  // do something
}

For Loop

//for loop is modified while loop; in for loop you know when to stop.
for (int i = 0; i < 10; i= i+1) {
  // do something
}
// same 😁
int i = 0;
while(i < 10) {
  // do something
  i= i+1;
}

if/else (Ternary Operator)

condition ? value1 : value2;
// if the condition is true, return value1, else return value2.

access the GitHub repo: Repo

🤝🏾Connect me on: Twitter: 🕊️@Abhayprajapati_ Github: 🐧@theabhayprajapati Linkedin: 📌@abhayprajaapati Youtube: 📺@Abhayprajapati

K
Kate4y ago

Great start Abhay Prajapati! By the way, the link to the Github repo seems broken.

1
A

Thank you, yah! it was broken, but now I have fixed it, have a look; https://github.com/theabhayprajapati/100DaysOfFlutter) "Link to the Github Repository