Mediator Pattern Dart: No More God Coordinators

The mediator pattern in Dart, done right: decouple your features through one lean coordinator instead of a god class. Full runnable code, when-to-use table, and the mistakes that recreate the mess.

Your cart service imports the payment service. The payment service calls the notification service. The notification service reads the cart to build its message โ€” and now every feature knows about every other feature. Change one, break three. The mediator pattern Dart developers reach for is the fix: put one coordinator in the middle, and let the features stop knowing about each other. But there's a trap waiting on the other side โ€” a fat mediator that just *becomes* the new god class. This guide shows you the lean version: full runnable code, the guardrails that keep the coordinator thin, and an honest table for when you'd rather use bloc, ChangeNotifier, or an event bus. What you'll learn The GoF mediator definition, in plain Dart The before/after: a tangled checkout flow vs. one lean coordinator How to keep the mediator from becoming a god object Mediator vs. bloc vs. ChangeNotifier vs. event bus (decision table) 5 mediator mistakes that rebuild the god object โ€” and the fixes ๐ŸŽฌ Watch: mediator pattern Watch the mediator pattern walkthrough โ€” the problem it fixes, the refactor, the trade-offs, and when not to use it โ€” before you build one in Dart. 11:02 โฑ 11:02 ยท Unknown โ€” click to play inline, or watch on YouTube . The Mediator pattern Dart developers keep asking about The Gang of Four defines it in one sentence: *define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.* In Dart terms: instead of class A calling class B calling class C, every class talks only to a mediator, and the mediator owns the interaction logic. The communicating objects are called colleagues ; the coordinator is the mediator .โ€ฆ

Explore