blob: 0251605c8a85020f7d4303e607350f458b06e273 [file] [log] [blame] [view] [edit]
# enableLifecycleEvents method
*[<Null safety>](https://dart.dev/null-safety)*
void enableLifecycleEvents
([Outgoing](../../package-fuchsia_services_services/Outgoing-class.md) outgoing)
<p>Initializes the shared <a href="../../package-fuchsia_modular_lifecycle/Lifecycle-class.md">Lifecycle</a> instance. This is required before
Lifecycle can be constructed.</p>
## Implementation
```dart
static void enableLifecycleEvents(Outgoing outgoing) {
if (_singleton == null) {
_singleton = LifecycleImpl(
outgoing: outgoing,
exitHandler: fuchsia.exit,
);
} else {
throw Exception(
'Attempted to call Lifecycle.enableLifecycleEvents after it has already been enabled. '
'Ensure that Lifecycle.enableLifecycleEvents is not called multiple times.');
}
}
```