resetServiceLocator function

Future<void> resetServiceLocator()

Unregisters everything setupServiceLocator registered.

Intended for tests, which need a clean container between cases — the setup is one-shot and would otherwise carry state across them.

Implementation

Future<void> resetServiceLocator() async {
  await _initLock.synchronized(() async {
    if (!_isInitialized) {
      return;
    }
    await getIt.reset();
    _isInitialized = false;
  });
}