From 3602edabb0192667bdaa95fcf8b6aa8dc6a092ee Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Tue, 1 Oct 2024 21:45:56 +0200 Subject: [PATCH] Fix typos --- lib/get_it.dart | 14 +++++++------- lib/get_it_impl.dart | 36 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/get_it.dart b/lib/get_it.dart index 1b19fe2..4b0db0d 100644 --- a/lib/get_it.dart +++ b/lib/get_it.dart @@ -30,7 +30,7 @@ abstract mixin class ShadowChangeHandlers { /// If objects that are registered inside GetIt implements [Disposable] the /// [onDispose] method will be called whenever that Object is unregistered, -/// resetted or its enclosing Scope is popped +/// reset or its enclosing Scope is popped abstract mixin class Disposable { FutureOr onDispose(); } @@ -153,7 +153,7 @@ abstract class GetIt { bool allowReassignment = false; /// By default it's throws error when [allowReassignment]= false. and trying to register same type - /// If you really need, you can disable the Asserts / Errror by setting[skipDoubleRegistration]= true + /// If you really need, you can disable the Asserts / Error by setting[skipDoubleRegistration]= true @visibleForTesting bool skipDoubleRegistration = false; @@ -343,7 +343,7 @@ abstract class GetIt { /// /// [registerSingletonIfAbsent] and [releaseInstance] are used to manage the lifecycle of /// a Singleton. This is useful if you register an object when you push a Page and this page can get - /// pused recursively. In that case you don't want to dispose the object when first of these pages is popped + /// pushed recursively. In that case you don't want to dispose the object when first of these pages is popped /// /// Only registers a type new as Singleton if it is not already registered. Otherwise it returns @@ -351,16 +351,16 @@ abstract class GetIt { /// [unregister] or [releaseInstance] calls will decrement the reference counter an won't unregister /// and dispose the registration as long as the reference counter is > 0. /// [T] type/interface that is used for the registration and the access via [get] - /// [factoryFunc] that is callled to create the instance if it is not already registered + /// [factoryFunc] that is called to create the instance if it is not already registered /// [instanceName] optional key to register more than one instance of one type - /// [dispose] disposing function that is autmatically called before the object is removed from get_it + /// [dispose] disposing function that is automatically called before the object is removed from get_it T registerSingletonIfAbsent( T Function() factoryFunc, { String? instanceName, DisposingFunc? dispose, }); - /// checks if a regiserter Singleton has an reference counter > 0 + /// checks if a registered Singleton has an reference counter > 0 /// if so it decrements the reference counter and if it reaches 0 it /// unregisters the Singleton /// if called on an object that's reference counter was never incremented @@ -576,7 +576,7 @@ abstract class GetIt { /// [instanceName] if you need to dispose any resources you can do it using /// [disposingFunction] function that provides an instance of your class to be disposed. /// This function overrides the disposing you might have provided when registering. - /// If you have enabled referece counting when registering, [unregister] will only unregister and dispose the object + /// If you have enabled reference counting when registering, [unregister] will only unregister and dispose the object /// if referenceCount is 0 /// [ignoreReferenceCount] if `true` it will ignore the reference count and unregister the object /// only use this if you know what you are doing diff --git a/lib/get_it_impl.dart b/lib/get_it_impl.dart index e196c87..eef29c5 100644 --- a/lib/get_it_impl.dart +++ b/lib/get_it_impl.dart @@ -38,7 +38,7 @@ enum _ServiceFactoryType { alwaysNew, // factory which means on every call of [get] a new instance is created constant, // normal singleton lazy, // lazy - cachedFactory, // cached factoryj + cachedFactory, // cached factory } /// If I use `Singleton` without specifier in the comments I mean normal and lazy @@ -114,7 +114,7 @@ class _ServiceFactory { final bool shouldSignalReady; - int _refenceCount = 0; + int _referenceCount = 0; _ServiceFactory( this._getItInstance, @@ -251,7 +251,7 @@ class _ServiceFactory { } /// returns an async instance depending on the type of the registration if [async==true] or - /// if [dependsOn.isnoEmpty]. + /// if [dependsOn.isNotEmpty]. Future getObjectAsync(dynamic param1, dynamic param2) async { assert( !(factoryType != _ServiceFactoryType.alwaysNew && @@ -512,7 +512,7 @@ class _GetItImplementation implements GetIt { bool allowReassignment = false; /// By default it's throws error when [allowReassignment]= false. and trying to register same type - /// If you really need, you can disable the Asserts / Errror by setting[skipDoubleRegistration]= true + /// If you really need, you can disable the Asserts / Error by setting[skipDoubleRegistration]= true @visibleForTesting @override bool skipDoubleRegistration = false; @@ -943,9 +943,9 @@ class _GetItImplementation implements GetIt { /// [unregister] or [releaseInstance] calls will decrement the reference counter an won't unregister /// and dispose the registration as long as the reference counter is > 0. /// [T] type/interface that is used for the registration and the access via [get] - /// [factoryFunc] that is callled to create the instance if it is not already registered + /// [factoryFunc] that is called to create the instance if it is not already registered /// [instanceName] optional key to register more than one instance of one type - /// [dispose] disposing function that is autmatically called before the object is removed from get_it + /// [dispose] disposing function that is automatically called before the object is removed from get_it @override T registerSingletonIfAbsent( T Function() factoryFunc, { @@ -960,7 +960,7 @@ class _GetItImplementation implements GetIt { !existingFactory.isAsync, StateError( 'registerSingletonIfAbsent can only be called for a type that is already registered as Singleton and not for factories or async/lazy Singletons')); - existingFactory._refenceCount++; + existingFactory._referenceCount++; return existingFactory.instance!; } @@ -976,20 +976,20 @@ class _GetItImplementation implements GetIt { return instance; } - /// checks if a regiserter Singleton has an reference counter > 0 + /// checks if a registered Singleton has an reference counter > 0 /// if so it decrements the reference counter and if it reaches 0 it /// unregisters the Singleton /// if called on an object that's reference counter was never incremented /// it will immediately unregister and dispose the object @override void releaseInstance(Object instance) { - final registerdFactory = _findFactoryByInstance(instance); - if (registerdFactory._refenceCount < 1) { - assert(registerdFactory._refenceCount == 0, + final registeredFactory = _findFactoryByInstance(instance); + if (registeredFactory._referenceCount < 1) { + assert(registeredFactory._referenceCount == 0, 'GetIt: releaseInstance was called on an object that was already released'); unregister(instance: instance); } else { - registerdFactory._refenceCount--; + registeredFactory._referenceCount--; } } @@ -1110,8 +1110,8 @@ class _GetItImplementation implements GetIt { /// Unregister an instance of an object or a factory/singleton by Type [T] or by name [instanceName] /// if you need to dispose any resources you can pass in a [disposingFunction] function /// that provides an instance of your class to be disposed - /// If you have provided an disposing functin when you registered the object that one will be called automatically - /// If you have enabled referece counting when registering, [unregister] will only unregister and dispose the object + /// If you have provided an disposing function when you registered the object that one will be called automatically + /// If you have enabled reference counting when registering, [unregister] will only unregister and dispose the object /// if referenceCount is 0 /// @override @@ -1132,8 +1132,8 @@ class _GetItImplementation implements GetIt { ), ); - if (factoryToRemove._refenceCount > 0) { - factoryToRemove._refenceCount--; + if (factoryToRemove._referenceCount > 0) { + factoryToRemove._referenceCount--; return; } final typeRegistration = factoryToRemove.registeredIn; @@ -1361,7 +1361,7 @@ class _GetItImplementation implements GetIt { } catch (e) { final failedScope = _scopes.last; - /// prevend any new registrations in this scope + /// prevent any new registrations in this scope failedScope.isFinal = true; failedScope.reset(dispose: true); _scopes.removeLast(); @@ -1416,7 +1416,7 @@ class _GetItImplementation implements GetIt { } catch (e) { final failedScope = _scopes.last; - /// prevend any new registrations in this scope + /// prevent any new registrations in this scope failedScope.isFinal = true; await failedScope.reset(dispose: true); _scopes.removeLast();