If you're learning clean code, you'll keep running into the "SOLID" principles. The L stands for the Liskov Substitution Principle (LSP) — a scary name for a genuinely simple idea. This guide starts from zero, so no prior knowledge is needed. What it is The Liskov Substitution Principle says: If something is supposed to work like a certain type, then any "version" of that type must be able to take its place without causing problems. That's the whole thing. If you call something a Doctor , it has to actually behave like a doctor everywhere a doctor is expected. If you call something an ApiClient , it has to behave like one everywhere. Break that, and your program fails — usually later, in a confusing way. The principle is named after Barbara Liskov, a computer scientist who described it back in 1987. But you don't need the academic version to use it well. First, what does "substitute" mean? This is the word that makes the whole pr...
In this blog post, we'll explore efficient state management in Flutter applications using ValueNotifier and EfficientBuilder within the MVVM (Model-View-ViewModel) architectural pattern. The MVVM architecture consists of three key components: Model: Represents the data and business logic View: Handles the UI presentation ViewModel: Manages state and business logic between Model and View In our approach, we’ll be refining the ViewModel by separating its states into a dedicated State class. This ensures that the ViewModel focuses solely on managing logic while the State class handles state representation. Traditionally, in MVVM, the ViewModel is responsible for both state management and business logic. However, by decoupling these concerns, we create a more structured and maintainable architecture. No more talking. Lets, implement it together. 1. Efficient Builder: We are going to use Efficient Builder package for this. So, go to pub.dev. Add the package to you pubspec.yaml file...