Member-only story
Flutter Design Patterns: 23 — Observer
An overview of the Observer design pattern and its implementation in Dart and Flutter

In the last article, I analysed a behavioural design pattern that reduces dependencies between a set of interacting objects by decoupling the interaction logic from the objects and moving it to a dedicated controller — Mediator. In this article, I would like to analyse and implement another behavioural design pattern that lets you define a publish-subscribe mechanism to notify multiple objects about any events that happen to the object they’re subscribed to — it is Observer.
Update 2022–09–15: I moved this blog to my personal website. For a better reading experience, up to date articles, interactive code examples and some extra content FOR FREE, check kazlauskas.dev.
Table of Contents
- What is the Observer design pattern?
- Analysis
- Implementation
- Other articles in this series
- Your contribution
What is the Observer design pattern?

Observer, also known as Dependents or Publish-Subscribe, belongs to the category of behavioural design patterns. The intention of this design pattern is described in the GoF book:
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Spoiler alert: if you have ever heard about reactive programming or even used the related frameworks/libraries/tools such as ReactiveX, RxDart or just basic streams in Dart, this design pattern won’t be a game-changer for you. But it is still worth knowing how reactive programming ideas are implemented in the OOP context from the ground up, though.
The motivation for this design pattern comes from the problem of having a collection of tightly coupled objects in the system…