Your First Flutter App: Polishing the App

Apr 12 2022 Dart 2.14.1, Flutter 2.5, Visual Studio Code

Part 1: Introduction to Dart

5. Use If Statements

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 4. Challenge: Calculate the Difference Next episode: 6. Challenge: Rewrite Your Code

This video was last updated on Apr 12 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

Let’s implement the algorithm we just designed to calculate the difference between the slider and the target value in Dart.

if (something is true) 
if (something is true) {
    then do this
}
} else if (something else is true) {
    then do this instead
}
} else {
    do something if neither of the above are true
}
const int maximumScore = 100;
int difference;
if (_model.current > _model.target) {

}
if (_model.current > _model.target) {
    difference = _model.current - _model.target;
}
else if (_model.target > _model.current) {

}
difference = _model.target - _model.current;;
} else {
    difference = 0;
}
return maximumScore - difference;