Dart Exception: Finally Clause

"Hello World, I'm Vinit Mepani, a coding virtuoso driven by passion, fueled by curiosity, and always poised to conquer challenges. Picture me as a digital explorer, navigating through the vast realms of code, forever in pursuit of innovation.
In the enchanting kingdom of algorithms and syntax, I wield my keyboard as a magical wand, casting spells of logic and crafting solutions to digital enigmas. With each line of code, I embark on an odyssey of learning, embracing the ever-evolving landscape of technology.
Eager to decode the secrets of the programming universe, I see challenges not as obstacles but as thrilling quests, opportunities to push boundaries and uncover new dimensions in the realm of possibilities.
In this symphony of zeros and ones, I am Vinit Mepani, a coder by passion, an adventurer in the digital wilderness, and a seeker of knowledge in the enchanting world of code. Join me on this quest, and let's create digital wonders together!"
We have already seen try , on and catch block now we finally see about the Finally Clause on dart Exception handing.
Finally Clouse means that this block will run compulsory even if we receive any exception or not it's does not matter. This block will run anyhow.
Syntax
Syntax:
try {
.....
}
on Exception1 {
....
}
catch Exception2 {
....
}
finally {
// code that should always execute; whether exception or not.
}
void main()
{
try{
int x= 5 ~/ 0;
print("The x valuse is $x");
}
catch(e , s)
{
print("Excepation : $e");
print(s);
}
finally{
print("Finally Clause");
}
}

Here, we can see that all the block executed even we receive the error of IntegerDivisionByZeroException still final block executed and we can see the output of the this.




