DEV Community

Cover image for 2/ 100DaysOfFlutter: Dart Control Startment/ Ternary Operator.
Abhay Prajapati
Abhay Prajapati

Posted on

4 3

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

Dart Control Startment

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

(Decision making) 🧠

if/else

if (condition) {
  // do something
} else {
  // do something else
}
Enter fullscreen mode Exit fullscreen mode

Switch

switch statement means when the value of 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
}
Enter fullscreen mode Exit fullscreen mode

(Loop/ Iteration) 🤹🏾

While Loop

which means until the condition is true the loop with continue the task,
dont' over-complicate the code,

while (condition) {
  // do something
}
Enter fullscreen mode Exit fullscreen mode

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;
}
Enter fullscreen mode Exit fullscreen mode

if/else (Ternary Operator)

condition ? value1 : value2;
// if the condition is true, return value1, else return value2.
Enter fullscreen mode Exit fullscreen mode

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

Sentry blog image

The Visual Studio App Center’s retiring

But sadly….you’re not. See how to make the switch to Sentry for all your crash reporting needs.

Read more

Top comments (0)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay