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).
import 'package:get/src/core/get_interface.dart';
import 'get_instance.dart';
extension Inst on GetInterface {
... ... @@ -14,8 +15,7 @@ extension Inst on GetInterface {
{String name, bool permanent = true}) =>
GetInstance().create<S>(builder, name: name, permanent: permanent);
S find<S>({String tag, FcBuilderFunc<S> instance}) =>
GetInstance().find<S>(tag: tag, instance: instance);
S find<S>({String tag}) => GetInstance().find<S>(tag: tag);
S put<S>(S dependency,
{String tag, bool permanent = false, FcBuilderFunc<S> builder}) =>
... ...
... ... @@ -153,7 +153,7 @@ class GetInstance {
// }
/// Find a instance from required class
S find<S>({String tag, FcBuilderFunc<S> instance}) {
S find<S>({String tag}) {
String key = _getKey(S, tag);
if (isRegistered<S>(tag: tag)) {
... ... @@ -207,16 +207,11 @@ class GetInstance {
/// Delete class instance on [S] and clean memory
Future<bool> delete<S>({String tag, String key, bool force = false}) async {
String newKey;
if (key == null) {
newKey = _getKey(S, tag);
} else {
newKey = key;
}
final newKey = key ?? _getKey(S, tag);
return queue.add<bool>(() async {
if (!_singl.containsKey(newKey)) {
GetConfig.log('[GETX] Instance $newKey already been removed.',
GetConfig.log('[GETX] Instance "$newKey" already removed.',
isError: true);
return false;
}
... ... @@ -224,7 +219,7 @@ class GetInstance {
FcBuilder builder = _singl[newKey] as FcBuilder;
if (builder.permanent && !force) {
GetConfig.log(
'[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.',
'[GETX] "$newKey" has been marked as permanent, SmartManagement is not authorized to delete it.',
isError: true);
return false;
}
... ... @@ -235,14 +230,14 @@ class GetInstance {
}
if (i is DisposableInterface) {
await i.onClose();
GetConfig.log('[GETX] onClose of $newKey called');
GetConfig.log('[GETX] "$newKey" onClose() called');
}
_singl.removeWhere((oldKey, value) => (oldKey == newKey));
if (_singl.containsKey(newKey)) {
GetConfig.log('[GETX] error on remove object $newKey', isError: true);
GetConfig.log('[GETX] error removing object "$newKey"', isError: true);
} else {
GetConfig.log('[GETX] $newKey deleted from memory');
GetConfig.log('[GETX] "$newKey" deleted from memory');
}
// _routesKey?.remove(key);
return true;
... ...