Singleton class

Marks a class as a singleton dependency.

By default the instance is created lazily on first access. Use Singleton.async to declare an asynchronous singleton.

Example:

@Singleton()
class MyService { ... }

@Singleton(lazy: false)
class EagerService { ... }
Inheritance
Implementers

Constructors

Singleton({bool lazy = true, bool weak = false})
Creates a Singleton annotation.
const
Singleton.async({bool lazy, bool weak})
Creates an asynchronous singleton provider.
const
factory

Properties

async bool
Whether the provider factory is asynchronous.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
lazy bool
Whether the singleton instance is created on first access rather than at module construction time.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
singleton bool
Whether the dependency is managed as a singleton.
finalinherited
weak bool
Whether the singleton instance may be garbage-collected when no strong references to it remain.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited