Exception_CustomException_Dart

 //Making Custom Exception by User(User defined Exception)

//
void main() {

try
{
checkAge(10);
}
catch(e)
{
print(e.toString());
}
}
void checkAge(int age)
{
if (age < 18) {
throw MyException("This is Eligible for Voting!");
}
}
class MyException implements Exception {

var message = "";
MyException(String msg)
{
this.message = msg;
}
@override
String toString()
{
return message;
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter