Dart Flow Control - Input Validation and User Controlled Loops

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Finally on the terminal and it is perfectly working after correcting the readLineSync error.💪

amosgaslin
Автор

Your explanation is amazing sir. Thank you

letscode
Автор

Johan, I've got a problem regarding the output, when I run the the application and enter the number in the range it prints out the number is invalid whilst my code is the exact same thing as this

aditiaarianugraha
Автор

Hello, I have an issue with the code below, each time I run it with an invalid number like 400 its showing invalid number but when I try to enter a valid number such as 23 0r 45 it's still printing out invalid number. Kindly help....

print('Please enter a number in the range of 1 through 100');
int number =

while (number < 1 || number > 100) {
print('The number is invalid');
print('Please enter a number in the range of 1 through 100');
int number =
}

print('$number is valid');

Bruno-obog
Автор

Hey Johan, Thank you for your videos. Please can you show me how you can create folders in windows manually ? or using cmd in windows because i try it it doesn t work for me when i try to open the file in the terminal in VSCODE .Thank you in advance .

megsfamily
Автор

Hi Johan, Firstly, Thanks for these wonderful tutorials. It's a saviour for a noob like me.
However, I am not able to validate and try-catch when a character (other than number) is entered. Will be greatful if you can help with the code below: (alos not sure if my code is correct )

import 'dart:io';

void main() {
String? number;

do {
stdout.write('Enter a number: ');
number = stdin.readLineSync();
try {
number ==
} catch (e) {
print('Please enter a number!');
}
} while (number == null || number.length == 0 || number.isEmpty);

int? num =

if (num.isEven) {
print('Even');
} else {
print('Odd');
}
}

nikashdeka