Handling Null exceptions in Dart(Try and catch block)

·

1 min read

As we go on writing programs for our users there are times where in our code we might have put some certain features and expect it to work when the program has been compiled successfully but then we get an error message saying 'uncaught exception', now don't be scared as this maybe as a result of an incorrect code or incorrect variable type assigned to another variable.

When we come at cross roads where we are not sure if the code will work then that is where we make use of the try and catch block

Capture.PNG

the try and catch block helps to catch exceptions/ errors coming from either the user or the programmer.

its syntax goes like this try{

}

catch(e){

} where e is means error or exception.