Objects and Classes
The starting point of OOP, objects, are instances of defined classes. In Dart, as has already been pointed out, everything is an object, that is, every value we can store in a variable is an instance of a class. Besides that, all objects also extend the Object class, directly or indirectly:
Dart classes can have both instance members (methods and fields) and class members (static methods and fields).
Dart classes do not support constructor overloading, but you can use the flexible function argument specifications from the language (optional, positional, and named) to provide different ways to instantiate a class. Also, you can have named constructors to define alternatives.
Encapsulation
Dart does not contain access restrictions explicitly, like the famous keywords used in Java—protected, private, and public. In Dart, encapsulation occurs at the library level instead of at the class level . The following also applies:
Dart creates implicit getters and setters for all fields in a class, so you can define how data is accessible to consumers and the way it changes.
In Dart, if an identifier (class, class member, top-level function, or variable) starts with an underscore( _ ), it's private to its library.
Inheritance and composition
Inheritance allows us to extend an object to specialized versions of some abstract type. In Dart, by simply declaring a class, we are already extending the Object type implicitly. The following also applies:
Dart permits single direct inheritance.
Dart has special support for mixins, which can be used to extend class functionalities without direct inheritance, simulating multiple inheritances, and reusing code.
Dart does not contain a final class directive like other languages; that is, a class can always be extended (have children).
Abstraction
Following inheritance, abstraction is the process whereby we define a type and its essential characteristics, moving to specialized types from parent ones. The following also applies:
Dart contains abstract classes that allow a definition of what something does/provides, without caring about how this is implemented.
Dart has the powerful implicit interface concept, which also makes every class an interface, allowing it to be implemented by others without extending it.
Polymorphism
Polymorphism is achieved by inheritance and can be regarded as the ability of an object to behave like another; for example, the int type is also a num type. The following also applies:
Dart allows overriding parent methods to change their original behavior.
Dart does not allow overloading in the way you may be familiar with. You cannot define the same method twice with different arguments. You can simulate overloading by using flexible argument definitions (that is, optional and positional, as seen in the previous Functions section) or not use it at all.