initScopeAsync method

Future<GetIt> initScopeAsync(
  1. String name, {
  2. required Future<void> init(
    1. GetItHelper gh
    ),
  3. ScopeDisposeFunc? dispose,
})

a helper method to push a new scope and init it's dependencies asynchronously inside of GetIt

Implementation

Future<GetIt> initScopeAsync(String name,
    {required Future<void> Function(GetItHelper gh) init,
    ScopeDisposeFunc? dispose}) {
  final completer = Completer<GetIt>();
  getIt.pushNewScope(
    scopeName: name,
    init: (getIt) async {
      await init(this);
      completer.complete(getIt);
    },
    dispose: dispose,
  );
  return completer.future;
}