Flutter Design Patterns: 16 — Decorator

An overview of the Decorator design pattern and its implementation in Dart and Flutter

Mangirdas Kazlauskas
Flutter Community

--

Previously in the series, I have analysed a relatively simple, but very practical design pattern — Proxy. This time I would like to represent a design pattern, that, unlike the Strategy design pattern, extends the functionality of an object instead of exchanging it. It is a structural design pattern called Decorator.

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 Decorator design pattern?
  • Analysis
  • Implementation
  • Other articles in this series
  • Your contribution

What is the Decorator design pattern?

When you see a separate class created for every possible combination of components (source)

Decorator, also known as Wrapper, is a structural design pattern, which intention in the GoF book is described like this:

--

--