Object Oriented Programming (OOP) in Dart - Introduction
Hello everyone! Today I am here to share the introduction of Object Oriented Programming (OOP) in dart.

What is OOP in Dart
OOP is an important concept and part of programming which is widely used. It helps us to deal with the real world data using the specified classes and their objects.
Another biggest benefit is that it helps us to organize the code. In procedural programming we write all the data in the main method and everything looks messy. But it helps us to write all the code in the specific classes and then we can call that data in the main method.
We can define the attributes of an object and then we can explain the function of that specific object in object oriented programming. For example a car is a real world object. We can create a car class and then we can define its attributes such as colour, price, model, etc and similarly then we define its working behaviour using the functions.
After creating the class and defining all the attributes and functions of a thing then we initialize that class in the main method. We call it by creating the object of that class and then by using that object or instance of that class we access the data inside the class.
These classes act as a blueprint and from this blueprint we can create other things. We create a common class and then using that blueprint of the class we can add any certain data.
In the dart programming language the class keyword is used to represent the class. I will show some examples here:
Create a class Car with:
- variables: brand, model, year
- function: addData(), showDetails() that prints all values.
- Create two objects and display their details.

Here you can see that I have declared all the required variables. I have set brand and model as String and year as an integer.

Here I have written the first function addData(). In this method the user will add the data and that data will be stored in the respective variables. Then this data will be used to show the details of the car.

Here I have written showDetails() method or a function to print all the details of the car. This function gets values from the user.

In the main method I have created the instance or object of the class Car.

Here you can see that I have accessed the functions of the class Car using its object.

I have run the program. It first called addData() method. The user input all the required details. After this showDetails() function is called and all the data of the car is printed.
🎉 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