Welcome Everyone - nehasharma20/Dart-Language- GitHub Wiki
Welcome to the Dart-Language- Learned From Practiced From
### Dart Language & OOP Concepts: A Quick Overview
What is Dart?
- A modern, object-oriented, class-defined, single-inheritance language.
- Developed by Google for building fast and scalable apps across various platforms (web, mobile, desktop, serverless).
- Features strong typing with optional type annotations for flexibility.
- Supports just-in-time (JIT) compilation for rapid development and ahead-of-time (AOT) compilation for production-ready native code.
- Emphasizes developer productivity and a delightful development experience.
Key Object-Oriented Programming (OOP) Concepts in Dart:
Classes and Objects:
- Blueprints (classes) for creating instances (objects).
- Objects encapsulate data (properties/fields) and behavior (methods/functions).
Encapsulation:
- Bundling data and methods that operate on the data within a single unit (class).
- Controls access to internal data through access modifiers (public, _private).
Inheritance:
- Mechanism for a class (subclass/child class) to inherit properties and methods from another class (superclass/parent class).
- Promotes code reusability and establishes "is-a" relationships.
- Dart supports single inheritance with the extends keyword.
Polymorphism:
- Ability of an object to take on many forms.
- Achieved through method overriding (providing a specific implementation in a subclass) and interface implementation.
- Allows writing more flexible and adaptable code.
Abstraction:
- Hiding complex implementation details and showing only essential information to the user.
- Achieved through abstract classes and interfaces.
- Focuses on "what" an object does rather than "how" it does it.
Interfaces (Implicit and Explicit):
- Define a contract of methods that a class can implement using the implements keyword.
- Dart implicitly defines an interface for every class.
Mixins:
- A way to reuse a class's code in multiple class hierarchies without using inheritance.
- Achieved using the with keyword.
- Avoids the complexities of multiple inheritance.
Key Dart Features Supporting OOP:
Constructors:
- Special methods for creating and initializing objects of a class.
- Getters and Setters: Special methods that provide controlled access to an object's properties.
- Operator Overloading: Ability to redefine the behavior of operators for custom classes.