Jonatas

update GetBuild to accept Object as ID

@@ -12,7 +12,7 @@ abstract class GetxController extends DisposableInterface with ListNotifier { @@ -12,7 +12,7 @@ abstract class GetxController extends DisposableInterface with ListNotifier {
12 /// `GetBuilder( id: )`, 12 /// `GetBuilder( id: )`,
13 /// [ids] can be reused among `GetBuilders` like group tags. 13 /// [ids] can be reused among `GetBuilders` like group tags.
14 /// The update will only notify the Widgets, if [condition] is true. 14 /// The update will only notify the Widgets, if [condition] is true.
15 - void update([List<String> ids, bool condition = true]) { 15 + void update([List<Object> ids, bool condition = true]) {
16 if (!condition) { 16 if (!condition) {
17 return; 17 return;
18 } 18 }
@@ -46,7 +46,7 @@ class _InheritedGetxController<T extends GetxController> @@ -46,7 +46,7 @@ class _InheritedGetxController<T extends GetxController>
46 class GetBuilder<T extends GetxController> extends StatefulWidget { 46 class GetBuilder<T extends GetxController> extends StatefulWidget {
47 final GetControllerBuilder<T> builder; 47 final GetControllerBuilder<T> builder;
48 final bool global; 48 final bool global;
49 - final String id; 49 + final Object id;
50 final String tag; 50 final String tag;
51 final bool autoRemove; 51 final bool autoRemove;
52 final bool assignId; 52 final bool assignId;
@@ -191,4 +191,3 @@ extension ObserverEtx on BuildContext { @@ -191,4 +191,3 @@ extension ObserverEtx on BuildContext {
191 return GetBuilder.of<T>(this, rebuild: true); 191 return GetBuilder.of<T>(this, rebuild: true);
192 } 192 }
193 } 193 }
194 -  
@@ -19,8 +19,8 @@ class ListNotifier implements Listenable { @@ -19,8 +19,8 @@ class ListNotifier implements Listenable {
19 19
20 List<GetStateUpdate> _updaters = <GetStateUpdate>[]; 20 List<GetStateUpdate> _updaters = <GetStateUpdate>[];
21 21
22 - HashMap<String, List<GetStateUpdate>> _updatersGroupIds =  
23 - HashMap<String, List<GetStateUpdate>>(); 22 + HashMap<Object, List<GetStateUpdate>> _updatersGroupIds =
  23 + HashMap<Object, List<GetStateUpdate>>();
24 24
25 @protected 25 @protected
26 void refresh() { 26 void refresh() {
@@ -44,7 +44,7 @@ class ListNotifier implements Listenable { @@ -44,7 +44,7 @@ class ListNotifier implements Listenable {
44 } 44 }
45 } 45 }
46 46
47 - void _notifyIdUpdate(String id) { 47 + void _notifyIdUpdate(Object id) {
48 if (_updatersGroupIds.containsKey(id)) { 48 if (_updatersGroupIds.containsKey(id)) {
49 final listGroup = _updatersGroupIds[id]; 49 final listGroup = _updatersGroupIds[id];
50 for (var item in listGroup) { 50 for (var item in listGroup) {
@@ -54,7 +54,7 @@ class ListNotifier implements Listenable { @@ -54,7 +54,7 @@ class ListNotifier implements Listenable {
54 } 54 }
55 55
56 @protected 56 @protected
57 - void refreshGroup(String id) { 57 + void refreshGroup(Object id) {
58 assert(_debugAssertNotDisposed()); 58 assert(_debugAssertNotDisposed());
59 59
60 /// This debounce the call to update. 60 /// This debounce the call to update.
@@ -101,7 +101,7 @@ class ListNotifier implements Listenable { @@ -101,7 +101,7 @@ class ListNotifier implements Listenable {
101 _updaters.remove(listener); 101 _updaters.remove(listener);
102 } 102 }
103 103
104 - void removeListenerId(String id, VoidCallback listener) { 104 + void removeListenerId(Object id, VoidCallback listener) {
105 assert(_debugAssertNotDisposed()); 105 assert(_debugAssertNotDisposed());
106 if (_updatersGroupIds.containsKey(id)) { 106 if (_updatersGroupIds.containsKey(id)) {
107 _updatersGroupIds[id].remove(listener); 107 _updatersGroupIds[id].remove(listener);
@@ -123,7 +123,7 @@ class ListNotifier implements Listenable { @@ -123,7 +123,7 @@ class ListNotifier implements Listenable {
123 return () => _updaters.remove(listener); 123 return () => _updaters.remove(listener);
124 } 124 }
125 125
126 - Disposer addListenerId(String key, GetStateUpdate listener) { 126 + Disposer addListenerId(Object key, GetStateUpdate listener) {
127 _updatersGroupIds[key] ??= <GetStateUpdate>[]; 127 _updatersGroupIds[key] ??= <GetStateUpdate>[];
128 _updatersGroupIds[key].add(listener); 128 _updatersGroupIds[key].add(listener);
129 return () => _updatersGroupIds[key].remove(listener); 129 return () => _updatersGroupIds[key].remove(listener);
@@ -132,7 +132,7 @@ class ListNotifier implements Listenable { @@ -132,7 +132,7 @@ class ListNotifier implements Listenable {
132 /// To dispose an [id] from future updates(), this ids are registered 132 /// To dispose an [id] from future updates(), this ids are registered
133 /// by [GetBuilder()] or similar, so is a way to unlink the state change with 133 /// by [GetBuilder()] or similar, so is a way to unlink the state change with
134 /// the Widget from the Controller. 134 /// the Widget from the Controller.
135 - void disposeId(String id) { 135 + void disposeId(Object id) {
136 _updatersGroupIds.remove(id); 136 _updatersGroupIds.remove(id);
137 } 137 }
138 } 138 }