Programming in Dart: Fundamentals

Apr 26 2022 · Dart 2.15, DartPad, DartPad

Part 1: Fundamentals

06. Set Conditional Values

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 05. Use Logical Operators Next episode: 07. Challenge: Play with Logical Operators

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

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

At this point, you should feel pretty good about working with logical operators. You’ve seen how combining them can produce a true or false value. But what if wanted to set a value based on the result of our logical operators? Often times, you’ll want to set a variable based on a condition.

Demo 1

We’ll get started by defining a message that we want to print out to console. So lets define a variable for the message to be presented.

String message;
var message;
String message;
const chrisHasPerfectAttendance = true;
const chrisGrade = 49;
const meritAwardGrade = 90;
const chrisIsMeritStudent = chrisHasPerfectAttendance && chrisGrade > meritAwardGrade;
if (chrisIsMeritStudent) {
    message = 'Congratulations';
else {
    message = 'Keep studying';
const samGrade = 99;
const betterStudent 
const betterStudent = (samGrade > chrisGrade)
? 'Sam' : 'Chris';