pushScope method

void pushScope({
  1. void init(
    1. GetIt getIt
    )?,
  2. void dispose()?,
})

Pushes a new GetIt-Scope. After pushing it executes init where you can register objects that should only exist as long as this scope exists. Can be called inside the build method method of a StatelessWidget. It ensures that it's only called once in the lifetime of a widget. When the widget is destroyed the scope too gets destroyed after dispose is executed. If you use this function and you have registered your objects with an async disposal function, that functions won't be awaited. I would recommend doing pushing and popping from your business layer but sometimes this might come in handy

Implementation

void pushScope(
        {void Function(GetIt getIt)? init, void Function()? dispose}) =>
    widget._state.value.pushScope(init: init, dispose: dispose);