Table of Contents
Get Started
Dart Installation
Dartpad
Local Setup
Comments in Dart
Variables
Numbers in Dart
Double in Dart
Integer in Dart
String in Dart
Operation on String
String Interpolation
Boolean in Dart
Operator
Decision Making
Switch in Dart
Ternary Operator
Loops
List in Dart
Operation on List
Map in Dart
Decision Making #
In decision making we will learn how to do different job based on the right and wrong decision.
Decision could be wrong or write and in other word we can also say, Our Assumption/Statement could be true or false
. I am saying this because bool
, this is completely related to boolean data.
To understand these example you must know
- int data type
- bool data type
Example 1 #
Let’s start with simple example.
void main(){
int a = 10;
int b = 20;
if(a < b){
// this will run only where a is less than b
print('Eligible for vote');
}
}
Example 2 #
Now, We will want to perform some action when the our decision gets wrong.
void main(){
int a = 10;
int b = 20;
if(a < b){
print('this will run only where a is less than b');
}else{
print('this will run only where a is not less than b')
}
}
Some more examples #
void main(){
int UserAge = 20;
int eligibleAgeToVoteAge = 18;
bool condition = UserAge > eligibleAgeToVoteAge;
if(condition){
// this will run when condition variable will true
print('Eligible for vote');
}else{
// this will run when condition variable will not true
print('Not eligible for vote');
}
}