@@ -17,6 +17,8 @@ void throwIfNot(bool condition, Object error) {
1717const _isDebugMode = ! bool .fromEnvironment ('dart.vm.product' ) &&
1818 ! bool .fromEnvironment ('dart.vm.profile' );
1919
20+ bool _devToolsExtensionRegistered = false ;
21+
2022void _debugOutput (Object message) {
2123 if (_isDebugMode) {
2224 if (! GetIt .noDebugOutput) {
@@ -549,33 +551,36 @@ class _GetItImplementation implements GetIt {
549551
550552 _GetItImplementation () {
551553 assert (() {
552- registerExtension ('ext.get_it.getRegistrations' ,
553- (method, parameters) async {
554- final registrations = < Map <String , dynamic >> [];
555- for (final scope in _scopes) {
556- for (final typeRegistration in scope.typeRegistrations.values) {
557- for (final registration in [
558- ...typeRegistration.registrations,
559- ...typeRegistration.namedRegistrations.values
560- ]) {
561- registrations.add ({
562- 'type' : registration.registeredWithType.toString (),
563- 'instanceName' : registration.instanceName,
564- 'scopeName' : scope.name,
565- 'registrationType' : registration.registrationType.toString (),
566- 'isAsync' : registration.isAsync,
567- 'isReady' : registration.isReady,
568- 'isCreated' : registration.instance != null ,
569- 'instanceDetails' : registration.instance != null
570- ? _getInstanceDetails (registration.instance! )
571- : null ,
572- });
554+ if (! _devToolsExtensionRegistered) {
555+ _devToolsExtensionRegistered = true ;
556+ registerExtension ('ext.get_it.getRegistrations' ,
557+ (method, parameters) async {
558+ final registrations = < Map <String , dynamic >> [];
559+ for (final scope in _scopes) {
560+ for (final typeRegistration in scope.typeRegistrations.values) {
561+ for (final registration in [
562+ ...typeRegistration.registrations,
563+ ...typeRegistration.namedRegistrations.values
564+ ]) {
565+ registrations.add ({
566+ 'type' : registration.registeredWithType.toString (),
567+ 'instanceName' : registration.instanceName,
568+ 'scopeName' : scope.name,
569+ 'registrationType' : registration.registrationType.toString (),
570+ 'isAsync' : registration.isAsync,
571+ 'isReady' : registration.isReady,
572+ 'isCreated' : registration.instance != null ,
573+ 'instanceDetails' : registration.instance != null
574+ ? _getInstanceDetails (registration.instance! )
575+ : null ,
576+ });
577+ }
573578 }
574579 }
575- }
576- return ServiceExtensionResponse . result (
577- jsonEncode ({ 'registrations' : registrations}) );
578- });
580+ return ServiceExtensionResponse . result (
581+ jsonEncode ({ 'registrations' : registrations}));
582+ } );
583+ }
579584 return true ;
580585 }());
581586 }
0 commit comments