Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
jonataslaw#2944
"$S" not found. You need to call "Get.put($S())" or "Get.lazyPut(()=>$S())"

#branch=dr/fix_not_found_viewController
#targetBranch=4ac2e3b Merge pull request jonataslaw#3095 from Aniketkhote/master
  • Loading branch information
dingrui committed May 17, 2024
1 parent 4ac2e3b commit 0a5c28f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/get_instance/src/extension_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ extension Inst on GetInterface {
if (_singl.containsKey(key)) {
final newDep = _singl[key];
if (newDep == null || !newDep.isDirty) {
return;
if (isSingleton == true) {
return;
} else {
delete<S>(tag: name, key: key);
dep = newDep as _InstanceBuilderFactory<S>;
dep.isDeleteByNextCreate = true;
}
} else {
dep = newDep as _InstanceBuilderFactory<S>;
}
Expand Down Expand Up @@ -366,6 +372,14 @@ extension Inst on GetInterface {

if (dep == null) return false;

if (dep.isDeleteByNextCreate) {
// fix:https://github.com/jonataslaw/getx/issues/2944
// Prevent the normal lifecycle from being unable to be destroyed
dep.isDeleteByNextCreate = false;
return false;
}


final _InstanceBuilderFactory builder;
if (dep.isDirty) {
builder = dep.lateRemove ?? dep;
Expand Down Expand Up @@ -508,6 +522,10 @@ class _InstanceBuilderFactory<S> {
/// For reusing [dependency] instead of [builderFunc]
bool? isSingleton;

// fix: https://github.com/jonataslaw/getx/issues/2944
// the identifier of the previous instance forcibly deleted when created
bool isDeleteByNextCreate = false;

/// When fenix mode is available, when a new instance is need
/// Instance manager will recreate a new instance of S
bool fenix;
Expand Down

0 comments on commit 0a5c28f

Please sign in to comment.