fixes Get.create() lifecycle.
Replying to an issue spotted by @Quent on Discord, this fixes the lifecycle ( `onInit()`, `onReady()`). `onClose()` has to be called manually by the dev in the created instance.
Showing
2 changed files
with
10 additions
and
0 deletions
@@ -74,3 +74,9 @@ captures/ | @@ -74,3 +74,9 @@ captures/ | ||
74 | !.vscode/tasks.json | 74 | !.vscode/tasks.json |
75 | !.vscode/launch.json | 75 | !.vscode/launch.json |
76 | !.vscode/extensions.json | 76 | !.vscode/extensions.json |
77 | + | ||
78 | +example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig | ||
79 | + | ||
80 | +example/macos/Flutter/ephemeral/ | ||
81 | + | ||
82 | +example/macos/Flutter/GeneratedPluginRegistrant.swift |
@@ -159,12 +159,16 @@ class GetInstance { | @@ -159,12 +159,16 @@ class GetInstance { | ||
159 | /// Optionally associating the current Route to the lifetime of the instance, | 159 | /// Optionally associating the current Route to the lifetime of the instance, |
160 | /// if [GetConfig.smartManagement] is marked as [SmartManagement.full] or | 160 | /// if [GetConfig.smartManagement] is marked as [SmartManagement.full] or |
161 | /// [GetConfig.keepFactory] | 161 | /// [GetConfig.keepFactory] |
162 | + /// Only flags `isInit` if it's using `Get.create()` | ||
163 | + /// (not for Singletons access). | ||
162 | bool _initDependencies<S>({String name}) { | 164 | bool _initDependencies<S>({String name}) { |
163 | final key = _getKey(S, name); | 165 | final key = _getKey(S, name); |
164 | final isInit = _singl[key].isInit; | 166 | final isInit = _singl[key].isInit; |
165 | if (!isInit) { | 167 | if (!isInit) { |
166 | _startController<S>(tag: name); | 168 | _startController<S>(tag: name); |
169 | + if (_singl[key].isSingleton) { | ||
167 | _singl[key].isInit = true; | 170 | _singl[key].isInit = true; |
171 | + } | ||
168 | if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { | 172 | if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { |
169 | _registerRouteInstance<S>(tag: name); | 173 | _registerRouteInstance<S>(tag: name); |
170 | } | 174 | } |
-
Please register or login to post a comment