IoCContainer decorate(Type type, {Type withDecorator})

Returns a copy of the container, with a decorator for this type bound.

class Greeter {
  greet() => "Hello, world";
}

class ExclaimDecorator implements Greeter {
  final Greeter _super;
  ExclaimDecorator(this._super);
  greet() => _super.greet() + '!';
}

class ScreamDecorator implements Greeter {
  final Greeter _super;
  ScreamDecorator(this._super);
  greet() => _super.greet().toUpperCase();
}

print(
  decorate(Greeter, withDecorator: ExclaimDecorator)
 .decorate(Greeter, withDecorator: ExclaimDecorator)
 .decorate(Greeter, withDecorator: ScreamDecorator)
 .make(Greeter)
 .greet()
); // HELLO, WORLD!!

Source

IoCContainer decorate(Type type, {Type withDecorator});