All I need to do with my code is if it passes the if
statement, it simply passes the class and moves on to the rest of the code, but in my research, I can't exactly figure out what the command may be. Is there a way to implement Python's pass
keyword in dart?
CodePudding user response:
There is no direct equivalent to the pass statement in Dart language. In Python, there are language restrictions that do not allow leaving empty loops, if statements and so on. However, in Dart it's completely OK to do that, you can just leave empty braces. For instance:
void main() {
for (int i = 0; i < 5; i ) {
// Ignored
}
try {
// Some logic
} on Exception {
// Ignored
}
if (true) {
// Ignored
}
}
There are even some lint rules that check for you not to leave empty logic (you can still add a comment and not leave them empty, though): empty_statements, empty_catches and so on.
CodePudding user response:
Just add empty curly braces {}
. For example:
const int num = 5;
if (num == 5) {
}
you don't have to provide code within the curly braces, it can be left empty.