Lazy constructor
const
Lazy([
- bool value = true
Indicates that a pod should be lazily initialized.
By default, pods are created eagerly at context startup.
Applying @Lazy()
will delay pod creation until it is first requested,
improving startup performance or avoiding unnecessary initialization.
Example
@Lazy()
class ExpensiveService {}
@Lazy(false)
class AlwaysEagerService {}
- Setting
value
totrue
enables lazy initialization (default). - Setting
value
tofalse
disables lazy initialization explicitly.
Implementation
const Lazy([this.value = true]);