Skip to content

Commit

Permalink
8.0.0-pre-3
Browse files Browse the repository at this point in the history
  • Loading branch information
escamoteur committed May 31, 2024
1 parent a6e806f commit 036d16d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## [8.0.0-pre-3] - 31.05.2024 releaseInstance will now throw if the instance isn't registered
## [8.0.0-pre-2] - 29.05.2024 fixing negitiv reference count
## [8.0.0-pre-1] - 26.05.2024
* `getAll()` and `getAllAsync()` now have a `fromAllScopes` parameter.
Expand Down
21 changes: 9 additions & 12 deletions lib/get_it_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -857,15 +857,13 @@ class _GetItImplementation implements GetIt {
/// it will immediately unregister and dispose the object
@override
void releaseInstance(Object instance) {
final registerdFactory = _findFirstFactoryByInstanceOrNull(instance);
if (registerdFactory != null) {
if (registerdFactory._refenceCount < 1) {
assert(registerdFactory._refenceCount == 0,
'GetIt: releaseInstance was called on an object that was already released');
unregister(instance: instance);
} else {
registerdFactory._refenceCount--;
}
final registerdFactory = _findFactoryByInstance(instance);
if (registerdFactory._refenceCount < 1) {
assert(registerdFactory._refenceCount == 0,
'GetIt: releaseInstance was called on an object that was already released');
unregister(instance: instance);
} else {
registerdFactory._refenceCount--;
}
}

Expand Down Expand Up @@ -1087,9 +1085,8 @@ class _GetItImplementation implements GetIt {
);

_ServiceFactory? _findFirstFactoryByInstanceOrNull(Object instance) {
final registeredFactories =
_allFactories.where((x) => identical(x.instance, instance));
return registeredFactories.isEmpty ? null : registeredFactories.first;
return _allFactories
.firstWhereOrNull((x) => identical(x.instance, instance));
}

_ServiceFactory _findFactoryByInstance(Object instance) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: get_it
description: Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App"
version: 8.0.0-pre-2
version: 8.0.0-pre-3
maintainer: Thomas Burkhart (@escamoteur)
homepage: https://github.com/fluttercommunity/get_it
funding:
Expand Down

0 comments on commit 036d16d

Please sign in to comment.