Abstraction in Dart
Hello everyone!
Today I am here to share Abstraction in Object Oriented Programming (OOP) in dart.

Abstraction is an important concept in OOP. It helps to write methods inside the abstract class and then the other classes can use those methods. The object of the abstract class cannot be created. Only the methods inside the abstract class can be used by other classes.
The abstract class is defined by using the abstract keyword at the start of declaring the class followed by the class keyword and the name of the class.

Here you can see I have created an abstract class Shape with only one method draw(). I used abstract keyword to make it abstract class.

I have created two child classes where I have extended the abstract class. But it is not like other inheritance as it is extending an abstract class. It requires the child classes to add the methods defined in the abstract class. The error will be removed when the child classes will have the defined method inside the abstract class.

Here you can see that I have added the required methods in the child classes. Now the errors have been removed. If you note that the method in the abstract class does not have body but in the child classes we have to define the body as well.

I have defined the bodies of the method in both the child classes. Now I am ready to move to the next level to call these methods in the main.

Here in the main I have created the objects of both the classes and then I have called the draw() method of each child class.

Each class override the draw() method and displays its own body.
This is how abstraction works in dart OOP which allows us to create methods inside the abstract class and then allows the child classes to override those methods in the concrete form.
We cannot directly access abstract class by creating its object but we can only extend the class by the child classes. If we try to create the object of the abstract class it will say that the abstract classes cannot be instantiated.
🎉 Congratulations!
Your post has been upvoted by the SteemX Team! 🚀
SteemX is a modern, user-friendly and powerful platform built for the Steem community.
🔗 Visit us: www.steemx.org
✅ Support our work — Vote for our witness: bountyking5
Visit: https://steemhop.org