so, I'm collecting input and using a while loop with the condition (if user omits input say...) I am using this while loop for several input collection in the same code so i decided to write a function for it with a couple parameters, however after user skips input and later enters it, it doesn't register, output should print "how are you $input"
however it just prints "how are you"
and leaves input blank
main() {
// First name
print('First name:');
var name1 = stdin.readLineSync();
void conds(name, shitbe) {
while (name.isEmpty) {
print('Field cannot be empty');
print(shitbe);
name = stdin.readLineSync();
}
}
conds(name1, 'First name:');
print('How are you $name1');
output should be like
PS C:\tools\Projects> dart playground.dart
First name:
Field cannot be empty
First name:
John
How are you John
PS C:\tools\Projects>
but this is what I'm getting after the first omission
PS C:\tools\Projects> dart test.dart
First name:
Field cannot be empty
First name:
John
How are you
PS C:\tools\Projects>