singleton top-level constant

Singleton const singleton

An injectable class or module provider that provides a single instance.

A dependency annotated with singleton will only be instantiated once. The same instance will be used to satisfy all dependencies.


class Foo {}

abstract class FooMaker {
  static final create = FooMaker$Injector.create;

  // identical(getFoo(), getFoo()) is guaranteed to be true.
  Foo getFoo();


const singleton = const Singleton._();