SOLID Principles in Flutter
9 min readAug 12, 2024
Enhancing Code Quality and Maintainability Through Five Key Design Principles.
Warning: Above image is purely a product of imagination. Any attempt to understand it may result in a spontaneous burst of creativity. Viewer discretion is advised!” 🎨 😄
- Single Responsibility Principle: “There should never be more than one reason for a class to change”. Each class should have only one central responsibility.
- Open-Closed Principle: “Software entities…” should be open for extension, but closed for modification.
- Liskov Substitution Principle: Function that uses pointers, reference of base classs, must be able to use object of derived classes without knowing it.
- The Interface Segregation Principle: Clients should not be forced to depend upon interfaces that they do not use.
- The Dependency Inversion Principle: Depend upon abstractions, [not] concretions.
Implementation
We will learn about the most fundamental design patterns in the industry.
Single Responsibility Principle (SRP) 🧑💻 🎯
class UserProfileManager {
void createUser(String name, String email) {
// Code to create a new user in the database
print('User created…