lundi 8 novembre 2021

How to write If statement in dart?

I am writing if statement like that:

String value;
if(int.parse(value)) // I want to write a condition that if error appear while parsing 
// (like value contains some strings) then if statement run

It can be achieved by writing try/catch

try{ 
int.parse(value)
}
catch (e) {
// implement if statement
}

But I want to do this with if statement

Aucun commentaire:

Enregistrer un commentaire