Rodrigo Lopez Peker

- Cleanup unused "instance" parameter in GetInstance::find()

- Cleanup log messages to have a more consistent format (still work to be done there).
1 import 'package:get/src/core/get_interface.dart'; 1 import 'package:get/src/core/get_interface.dart';
  2 +
2 import 'get_instance.dart'; 3 import 'get_instance.dart';
3 4
4 extension Inst on GetInterface { 5 extension Inst on GetInterface {
@@ -14,8 +15,7 @@ extension Inst on GetInterface { @@ -14,8 +15,7 @@ extension Inst on GetInterface {
14 {String name, bool permanent = true}) => 15 {String name, bool permanent = true}) =>
15 GetInstance().create<S>(builder, name: name, permanent: permanent); 16 GetInstance().create<S>(builder, name: name, permanent: permanent);
16 17
17 - S find<S>({String tag, FcBuilderFunc<S> instance}) =>  
18 - GetInstance().find<S>(tag: tag, instance: instance); 18 + S find<S>({String tag}) => GetInstance().find<S>(tag: tag);
19 19
20 S put<S>(S dependency, 20 S put<S>(S dependency,
21 {String tag, bool permanent = false, FcBuilderFunc<S> builder}) => 21 {String tag, bool permanent = false, FcBuilderFunc<S> builder}) =>
@@ -153,7 +153,7 @@ class GetInstance { @@ -153,7 +153,7 @@ class GetInstance {
153 // } 153 // }
154 154
155 /// Find a instance from required class 155 /// Find a instance from required class
156 - S find<S>({String tag, FcBuilderFunc<S> instance}) { 156 + S find<S>({String tag}) {
157 String key = _getKey(S, tag); 157 String key = _getKey(S, tag);
158 158
159 if (isRegistered<S>(tag: tag)) { 159 if (isRegistered<S>(tag: tag)) {
@@ -207,16 +207,11 @@ class GetInstance { @@ -207,16 +207,11 @@ class GetInstance {
207 207
208 /// Delete class instance on [S] and clean memory 208 /// Delete class instance on [S] and clean memory
209 Future<bool> delete<S>({String tag, String key, bool force = false}) async { 209 Future<bool> delete<S>({String tag, String key, bool force = false}) async {
210 - String newKey;  
211 - if (key == null) {  
212 - newKey = _getKey(S, tag);  
213 - } else {  
214 - newKey = key;  
215 - } 210 + final newKey = key ?? _getKey(S, tag);
216 211
217 return queue.add<bool>(() async { 212 return queue.add<bool>(() async {
218 if (!_singl.containsKey(newKey)) { 213 if (!_singl.containsKey(newKey)) {
219 - GetConfig.log('[GETX] Instance $newKey already been removed.', 214 + GetConfig.log('[GETX] Instance "$newKey" already removed.',
220 isError: true); 215 isError: true);
221 return false; 216 return false;
222 } 217 }
@@ -224,7 +219,7 @@ class GetInstance { @@ -224,7 +219,7 @@ class GetInstance {
224 FcBuilder builder = _singl[newKey] as FcBuilder; 219 FcBuilder builder = _singl[newKey] as FcBuilder;
225 if (builder.permanent && !force) { 220 if (builder.permanent && !force) {
226 GetConfig.log( 221 GetConfig.log(
227 - '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.', 222 + '[GETX] "$newKey" has been marked as permanent, SmartManagement is not authorized to delete it.',
228 isError: true); 223 isError: true);
229 return false; 224 return false;
230 } 225 }
@@ -235,14 +230,14 @@ class GetInstance { @@ -235,14 +230,14 @@ class GetInstance {
235 } 230 }
236 if (i is DisposableInterface) { 231 if (i is DisposableInterface) {
237 await i.onClose(); 232 await i.onClose();
238 - GetConfig.log('[GETX] onClose of $newKey called'); 233 + GetConfig.log('[GETX] "$newKey" onClose() called');
239 } 234 }
240 235
241 _singl.removeWhere((oldKey, value) => (oldKey == newKey)); 236 _singl.removeWhere((oldKey, value) => (oldKey == newKey));
242 if (_singl.containsKey(newKey)) { 237 if (_singl.containsKey(newKey)) {
243 - GetConfig.log('[GETX] error on remove object $newKey', isError: true); 238 + GetConfig.log('[GETX] error removing object "$newKey"', isError: true);
244 } else { 239 } else {
245 - GetConfig.log('[GETX] $newKey deleted from memory'); 240 + GetConfig.log('[GETX] "$newKey" deleted from memory');
246 } 241 }
247 // _routesKey?.remove(key); 242 // _routesKey?.remove(key);
248 return true; 243 return true;