Committed by
GitHub
Showing
12 changed files
with
201 additions
and
157 deletions
1 | +## [3.4.0] | ||
2 | +- Added '[everAll]' Worker: Listen a List of '.obx' | ||
3 | +- Added Workers dispose | ||
4 | +- Fix transition.noTransition | ||
5 | +- Fix TextField and VideoPlayController dispose before transition animation | ||
6 | + | ||
1 | ## [3.3.0] | 7 | ## [3.3.0] |
2 | - Fix extensions (@stefandevo) | 8 | - Fix extensions (@stefandevo) |
3 | - Added CPF to utils options (@kauemurakami) | 9 | - Added CPF to utils options (@kauemurakami) |
@@ -41,7 +41,7 @@ extension MDQ on BuildContext { | @@ -41,7 +41,7 @@ extension MDQ on BuildContext { | ||
41 | dividedBy; | 41 | dividedBy; |
42 | } | 42 | } |
43 | 43 | ||
44 | - /// TODO: make docs about that | 44 | + /// Divide the height proportionally by the given value |
45 | double ratio({ | 45 | double ratio({ |
46 | double dividedBy = 1, | 46 | double dividedBy = 1, |
47 | double reducedByW = 0.0, | 47 | double reducedByW = 0.0, |
@@ -870,13 +870,13 @@ class GetImpl implements GetService { | @@ -870,13 +870,13 @@ class GetImpl implements GetService { | ||
870 | 870 | ||
871 | RouteSettings get routeSettings => settings; | 871 | RouteSettings get routeSettings => settings; |
872 | 872 | ||
873 | - Routing _routing = Routing(); | 873 | + final _routing = Routing(); |
874 | 874 | ||
875 | Map<String, String> parameters = {}; | 875 | Map<String, String> parameters = {}; |
876 | 876 | ||
877 | - void setRouting(Routing rt) { | ||
878 | - _routing = rt; | ||
879 | - } | 877 | + // void setRouting(Routing rt) { |
878 | + // _routing = rt; | ||
879 | + // } | ||
880 | 880 | ||
881 | void setSettings(RouteSettings settings) { | 881 | void setSettings(RouteSettings settings) { |
882 | settings = settings; | 882 | settings = settings; |
@@ -129,7 +129,7 @@ class GetInstance { | @@ -129,7 +129,7 @@ class GetInstance { | ||
129 | 129 | ||
130 | if (i is DisposableInterface) { | 130 | if (i is DisposableInterface) { |
131 | i.onStart(); | 131 | i.onStart(); |
132 | - if (GetConfig.isLogEnable) print('[GET] $key has been initialized'); | 132 | + if (GetConfig.isLogEnable) print('[GETX] $key has been initialized'); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
@@ -162,7 +162,7 @@ class GetInstance { | @@ -162,7 +162,7 @@ class GetInstance { | ||
162 | throw " $S not found. You need call put<$S>($S()) before"; | 162 | throw " $S not found. You need call put<$S>($S()) before"; |
163 | 163 | ||
164 | if (GetConfig.isLogEnable) | 164 | if (GetConfig.isLogEnable) |
165 | - print('[GET] $S instance was created at that time'); | 165 | + print('[GETX] $S instance was created at that time'); |
166 | S _value = put<S>(GetConfig._factory[key].builder() as S); | 166 | S _value = put<S>(GetConfig._factory[key].builder() as S); |
167 | 167 | ||
168 | if (!isDependencyInit<S>() && | 168 | if (!isDependencyInit<S>() && |
@@ -192,13 +192,13 @@ class GetInstance { | @@ -192,13 +192,13 @@ class GetInstance { | ||
192 | 192 | ||
193 | if (i is DisposableInterface) { | 193 | if (i is DisposableInterface) { |
194 | i.onClose(); | 194 | i.onClose(); |
195 | - if (GetConfig.isLogEnable) print('[GET] onClose of $key called'); | 195 | + if (GetConfig.isLogEnable) print('[GETX] onClose of $key called'); |
196 | } | 196 | } |
197 | if (builder != null) builder.dependency = null; | 197 | if (builder != null) builder.dependency = null; |
198 | if (GetConfig._singl.containsKey(key)) { | 198 | if (GetConfig._singl.containsKey(key)) { |
199 | print('error on remove $key'); | 199 | print('error on remove $key'); |
200 | } else { | 200 | } else { |
201 | - if (GetConfig.isLogEnable) print('[GET] $key removed from memory'); | 201 | + if (GetConfig.isLogEnable) print('[GETX] $key removed from memory'); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
@@ -230,21 +230,21 @@ class GetInstance { | @@ -230,21 +230,21 @@ class GetInstance { | ||
230 | FcBuilder builder = GetConfig._singl[newKey] as FcBuilder; | 230 | FcBuilder builder = GetConfig._singl[newKey] as FcBuilder; |
231 | if (builder.permanent) { | 231 | if (builder.permanent) { |
232 | print( | 232 | print( |
233 | - '[GET] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.'); | 233 | + '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.'); |
234 | return false; | 234 | return false; |
235 | } | 235 | } |
236 | final i = builder.dependency; | 236 | final i = builder.dependency; |
237 | 237 | ||
238 | if (i is DisposableInterface) { | 238 | if (i is DisposableInterface) { |
239 | await i.onClose(); | 239 | await i.onClose(); |
240 | - if (GetConfig.isLogEnable) print('[GET] onClose of $newKey called'); | 240 | + if (GetConfig.isLogEnable) print('[GETX] onClose of $newKey called'); |
241 | } | 241 | } |
242 | 242 | ||
243 | GetConfig._singl.removeWhere((oldkey, value) => (oldkey == newKey)); | 243 | GetConfig._singl.removeWhere((oldkey, value) => (oldkey == newKey)); |
244 | if (GetConfig._singl.containsKey(newKey)) { | 244 | if (GetConfig._singl.containsKey(newKey)) { |
245 | - print('[GET] error on remove object $newKey'); | 245 | + print('[GETX] error on remove object $newKey'); |
246 | } else { | 246 | } else { |
247 | - if (GetConfig.isLogEnable) print('[GET] $newKey deleted from memory'); | 247 | + if (GetConfig.isLogEnable) print('[GETX] $newKey deleted from memory'); |
248 | } | 248 | } |
249 | // GetConfig.routesKey?.remove(key); | 249 | // GetConfig.routesKey?.remove(key); |
250 | return true; | 250 | return true; |
@@ -180,6 +180,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -180,6 +180,8 @@ class GetMaterialApp extends StatelessWidget { | ||
180 | onDispose?.call(); | 180 | onDispose?.call(); |
181 | }, | 181 | }, |
182 | initState: (i) { | 182 | initState: (i) { |
183 | + print( | ||
184 | + '[GETX] INITIALIZED: If you need help, join our community support channels: https://tinyurl.com/y3cp88l3'); | ||
183 | if (locale != null) { | 185 | if (locale != null) { |
184 | Get.locale = locale; | 186 | Get.locale = locale; |
185 | } | 187 | } |
@@ -221,8 +223,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -221,8 +223,8 @@ class GetMaterialApp extends StatelessWidget { | ||
221 | : initialRoutesGenerate, | 223 | : initialRoutesGenerate, |
222 | onUnknownRoute: onUnknownRoute, | 224 | onUnknownRoute: onUnknownRoute, |
223 | navigatorObservers: (navigatorObservers == null | 225 | navigatorObservers: (navigatorObservers == null |
224 | - ? <NavigatorObserver>[GetObserver(routingCallback)] | ||
225 | - : <NavigatorObserver>[GetObserver(routingCallback)] | 226 | + ? <NavigatorObserver>[GetObserver(routingCallback, Get.routing)] |
227 | + : <NavigatorObserver>[GetObserver(routingCallback, Get.routing)] | ||
226 | ..addAll(navigatorObservers)), | 228 | ..addAll(navigatorObservers)), |
227 | builder: builder, | 229 | builder: builder, |
228 | title: title ?? '', | 230 | title: title ?? '', |
@@ -3,6 +3,7 @@ import 'dart:ui' show lerpDouble; | @@ -3,6 +3,7 @@ import 'dart:ui' show lerpDouble; | ||
3 | import 'package:flutter/cupertino.dart'; | 3 | import 'package:flutter/cupertino.dart'; |
4 | import 'package:flutter/gestures.dart'; | 4 | import 'package:flutter/gestures.dart'; |
5 | import 'package:flutter/material.dart'; | 5 | import 'package:flutter/material.dart'; |
6 | +import 'package:get/route_manager.dart'; | ||
6 | import 'package:get/src/get_main.dart'; | 7 | import 'package:get/src/get_main.dart'; |
7 | import 'package:get/src/instance/get_instance.dart'; | 8 | import 'package:get/src/instance/get_instance.dart'; |
8 | import 'package:get/utils.dart'; | 9 | import 'package:get/utils.dart'; |
@@ -129,6 +130,14 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -129,6 +130,14 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
129 | bool get popGestureInProgress => isPopGestureInProgress(this); | 130 | bool get popGestureInProgress => isPopGestureInProgress(this); |
130 | 131 | ||
131 | @override | 132 | @override |
133 | + void dispose() { | ||
134 | + if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { | ||
135 | + GetInstance().removeDependencyByRoute("${settings.name}"); | ||
136 | + } | ||
137 | + super.dispose(); | ||
138 | + } | ||
139 | + | ||
140 | + @override | ||
132 | Widget buildTransitions(BuildContext context, Animation<double> animation, | 141 | Widget buildTransitions(BuildContext context, Animation<double> animation, |
133 | Animation<double> secondaryAnimation, Widget child) { | 142 | Animation<double> secondaryAnimation, Widget child) { |
134 | if (fullscreenDialog && transition == null) { | 143 | if (fullscreenDialog && transition == null) { |
@@ -197,6 +206,14 @@ class GetPageRoute<T> extends PageRoute<T> { | @@ -197,6 +206,14 @@ class GetPageRoute<T> extends PageRoute<T> { | ||
197 | child: child) | 206 | child: child) |
198 | : child); | 207 | : child); |
199 | 208 | ||
209 | + case Transition.noTransition: | ||
210 | + return popGesture ?? Get.defaultPopGesture | ||
211 | + ? _CupertinoBackGestureDetector<T>( | ||
212 | + enabledCallback: () => _isPopGestureEnabled<T>(this), | ||
213 | + onStartPopGesture: () => _startPopGesture<T>(this), | ||
214 | + child: child) | ||
215 | + : child; | ||
216 | + | ||
200 | case Transition.rightToLeft: | 217 | case Transition.rightToLeft: |
201 | return SlideRightTransition().buildTransitions( | 218 | return SlideRightTransition().buildTransitions( |
202 | context, | 219 | context, |
1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
2 | import 'package:get/src/instance/get_instance.dart'; | 2 | import 'package:get/src/instance/get_instance.dart'; |
3 | -import 'package:get/src/root/smart_management.dart'; | ||
4 | -import '../../get_main.dart'; | ||
5 | 3 | ||
6 | class Routing { | 4 | class Routing { |
7 | String current; | 5 | String current; |
@@ -14,22 +12,28 @@ class Routing { | @@ -14,22 +12,28 @@ class Routing { | ||
14 | bool isBottomSheet; | 12 | bool isBottomSheet; |
15 | bool isDialog; | 13 | bool isDialog; |
16 | Routing({ | 14 | Routing({ |
17 | - this.current, | ||
18 | - this.previous, | 15 | + this.current = '', |
16 | + this.previous = '', | ||
19 | this.args, | 17 | this.args, |
20 | - this.removed, | 18 | + this.removed = '', |
21 | this.route, | 19 | this.route, |
22 | this.isBack, | 20 | this.isBack, |
23 | this.isSnackbar, | 21 | this.isSnackbar, |
24 | this.isBottomSheet, | 22 | this.isBottomSheet, |
25 | this.isDialog, | 23 | this.isDialog, |
26 | }); | 24 | }); |
25 | + | ||
26 | + void update(void fn(Routing value)) { | ||
27 | + fn(this); | ||
28 | + GetConfig.currentRoute = this.current; | ||
29 | + } | ||
27 | } | 30 | } |
28 | 31 | ||
29 | class GetObserver extends NavigatorObserver { | 32 | class GetObserver extends NavigatorObserver { |
30 | final Function(Routing) routing; | 33 | final Function(Routing) routing; |
31 | 34 | ||
32 | - GetObserver([this.routing]); | 35 | + GetObserver([this.routing, this._routeSend]); |
36 | + final Routing _routeSend; | ||
33 | 37 | ||
34 | Route<dynamic> route; | 38 | Route<dynamic> route; |
35 | bool isBack; | 39 | bool isBack; |
@@ -46,43 +50,30 @@ class GetObserver extends NavigatorObserver { | @@ -46,43 +50,30 @@ class GetObserver extends NavigatorObserver { | ||
46 | void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { | 50 | void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { |
47 | if ('${route?.settings?.name}' == 'snackbar') { | 51 | if ('${route?.settings?.name}' == 'snackbar') { |
48 | if (GetConfig.isLogEnable) | 52 | if (GetConfig.isLogEnable) |
49 | - print("[OPEN SNACKBAR] ${route?.settings?.name}"); | 53 | + print("[GETX] OPEN SNACKBAR ${route?.settings?.name}"); |
50 | } else if ('${route?.settings?.name}' == 'bottomsheet') { | 54 | } else if ('${route?.settings?.name}' == 'bottomsheet') { |
51 | if (GetConfig.isLogEnable) | 55 | if (GetConfig.isLogEnable) |
52 | - print("[OPEN BOTTOMSHEET] ${route?.settings?.name}"); | 56 | + print("[GETX] OPEN BOTTOMSHEET ${route?.settings?.name}"); |
53 | } else if ('${route?.settings?.name}' == 'dialog') { | 57 | } else if ('${route?.settings?.name}' == 'dialog') { |
54 | if (GetConfig.isLogEnable) | 58 | if (GetConfig.isLogEnable) |
55 | - print("[OPEN DIALOG] ${route?.settings?.name}"); | 59 | + print("[GETX] OPEN DIALOG ${route?.settings?.name}"); |
56 | } else { | 60 | } else { |
57 | if (GetConfig.isLogEnable) | 61 | if (GetConfig.isLogEnable) |
58 | - print("[GOING TO ROUTE] ${route?.settings?.name}"); | 62 | + print("[GETX] GOING TO ROUTE ${route?.settings?.name}"); |
59 | } | 63 | } |
60 | 64 | ||
61 | - isSnackbar = '${route?.settings?.name}' == 'snackbar'; | ||
62 | - isDialog = '${route?.settings?.name}' == 'dialog'; | ||
63 | - isBottomSheet = '${route?.settings?.name}' == 'bottomsheet'; | ||
64 | - current = '${route?.settings?.name}'; | ||
65 | - previous = '${previousRoute?.settings?.name}'; | ||
66 | - args = route?.settings?.arguments; | ||
67 | - // previousArgs = previousRoute?.settings?.arguments; | ||
68 | - | ||
69 | - final routeSend = Routing( | ||
70 | - removed: null, | ||
71 | - isBack: false, | ||
72 | - route: route, | ||
73 | - current: '${route?.settings?.name}', | ||
74 | - previous: '${previousRoute?.settings?.name}', | ||
75 | - args: route?.settings?.arguments, | ||
76 | - // previousArgs: previousRoute?.settings?.arguments, | ||
77 | - isSnackbar: isSnackbar, | ||
78 | - isDialog: isDialog, | ||
79 | - isBottomSheet: isBottomSheet, | ||
80 | - ); | ||
81 | - if (routing != null) { | ||
82 | - routing(routeSend); | ||
83 | - } | ||
84 | - GetConfig.currentRoute = current; | ||
85 | - Get.setRouting(routeSend); | 65 | + _routeSend.update((value) { |
66 | + if (route is PageRoute) value.current = '${route?.settings?.name}'; | ||
67 | + value.args = route?.settings?.arguments; | ||
68 | + value.route = route; | ||
69 | + value.isBack = false; | ||
70 | + value.removed = ''; | ||
71 | + value.previous = '${previousRoute?.settings?.name}'; | ||
72 | + value.isSnackbar = '${route?.settings?.name}' == 'snackbar'; | ||
73 | + value.isBottomSheet = '${route?.settings?.name}' == 'bottomsheet'; | ||
74 | + value.isDialog = '${route?.settings?.name}' == 'dialog'; | ||
75 | + }); | ||
76 | + if (routing != null) routing(_routeSend); | ||
86 | } | 77 | } |
87 | 78 | ||
88 | @override | 79 | @override |
@@ -91,112 +82,67 @@ class GetObserver extends NavigatorObserver { | @@ -91,112 +82,67 @@ class GetObserver extends NavigatorObserver { | ||
91 | 82 | ||
92 | if ('${route?.settings?.name}' == 'snackbar') { | 83 | if ('${route?.settings?.name}' == 'snackbar') { |
93 | if (GetConfig.isLogEnable) | 84 | if (GetConfig.isLogEnable) |
94 | - print("[CLOSE SNACKBAR] ${route?.settings?.name}"); | 85 | + print("[GETX] CLOSE SNACKBAR ${route?.settings?.name}"); |
95 | } else if ('${route?.settings?.name}' == 'bottomsheet') { | 86 | } else if ('${route?.settings?.name}' == 'bottomsheet') { |
96 | if (GetConfig.isLogEnable) | 87 | if (GetConfig.isLogEnable) |
97 | - print("[CLOSE BOTTOMSHEET] ${route?.settings?.name}"); | 88 | + print("[GETX] CLOSE BOTTOMSHEET ${route?.settings?.name}"); |
98 | } else if ('${route?.settings?.name}' == 'dialog') { | 89 | } else if ('${route?.settings?.name}' == 'dialog') { |
99 | if (GetConfig.isLogEnable) | 90 | if (GetConfig.isLogEnable) |
100 | - print("[CLOSE DIALOG] ${route?.settings?.name}"); | 91 | + print("[GETX] CLOSE DIALOG ${route?.settings?.name}"); |
101 | } else { | 92 | } else { |
102 | - if (GetConfig.isLogEnable) print("[BACK ROUTE] ${route?.settings?.name}"); | ||
103 | - } | ||
104 | - | ||
105 | - if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { | ||
106 | - GetInstance().removeDependencyByRoute("${route?.settings?.name}"); | 93 | + if (GetConfig.isLogEnable) |
94 | + print("[GETX] BACK ROUTE ${route?.settings?.name}"); | ||
107 | } | 95 | } |
108 | 96 | ||
109 | - isSnackbar = false; | ||
110 | - isDialog = false; | ||
111 | - isBottomSheet = false; | ||
112 | - current = '${previousRoute?.settings?.name}'; | ||
113 | - previous = '${route?.settings?.name}'; | ||
114 | - args = previousRoute?.settings?.arguments; | ||
115 | - // previousArgs = route?.settings?.arguments; | ||
116 | - | ||
117 | - final routeSend = Routing( | ||
118 | - removed: null, | ||
119 | - isBack: true, | ||
120 | - route: previousRoute, | ||
121 | - current: '${previousRoute?.settings?.name}', | ||
122 | - previous: '${route?.settings?.name}', | ||
123 | - args: previousRoute?.settings?.arguments, | ||
124 | - // previousArgs: route?.settings?.arguments, | ||
125 | - isSnackbar: false, //'${route?.settings?.name}' == 'snackbar', | ||
126 | - isDialog: false, //'${route?.settings?.name}' == 'dialog', | ||
127 | - isBottomSheet: false, //'${route?.settings?.name}' == 'bottomsheet', | ||
128 | - ); | ||
129 | - | ||
130 | - if (routing != null) { | ||
131 | - routing(routeSend); | ||
132 | - } | ||
133 | - GetConfig.currentRoute = current; | ||
134 | - Get.setRouting(routeSend); | 97 | + _routeSend.update((value) { |
98 | + if (previousRoute is PageRoute) | ||
99 | + value.current = '${previousRoute?.settings?.name}'; | ||
100 | + value.args = route?.settings?.arguments; | ||
101 | + value.route = previousRoute; | ||
102 | + value.isBack = true; | ||
103 | + value.removed = ''; | ||
104 | + value.previous = '${route?.settings?.name}'; | ||
105 | + value.isSnackbar = false; | ||
106 | + value.isBottomSheet = false; | ||
107 | + value.isDialog = false; | ||
108 | + }); | ||
109 | + if (routing != null) routing(_routeSend); | ||
135 | } | 110 | } |
136 | 111 | ||
137 | @override | 112 | @override |
138 | void didReplace({Route newRoute, Route oldRoute}) { | 113 | void didReplace({Route newRoute, Route oldRoute}) { |
139 | super.didReplace(newRoute: newRoute, oldRoute: oldRoute); | 114 | super.didReplace(newRoute: newRoute, oldRoute: oldRoute); |
140 | if (GetConfig.isLogEnable) | 115 | if (GetConfig.isLogEnable) |
141 | - print("[REPLACE ROUTE] ${oldRoute?.settings?.name}"); | ||
142 | - if (GetConfig.isLogEnable) print("[NEW ROUTE] ${newRoute?.settings?.name}"); | ||
143 | - | ||
144 | - if (GetConfig.smartManagement == SmartManagement.full) { | ||
145 | - GetInstance().removeDependencyByRoute("${oldRoute?.settings?.name}"); | ||
146 | - } | ||
147 | - | ||
148 | - isSnackbar = false; | ||
149 | - isDialog = false; | ||
150 | - isBottomSheet = false; | ||
151 | - | ||
152 | - final routeSend = Routing( | ||
153 | - removed: null, // add '${oldRoute?.settings?.name}' or remain null ??? | ||
154 | - isBack: false, | ||
155 | - route: newRoute, | ||
156 | - current: '${newRoute?.settings?.name}', | ||
157 | - previous: '${oldRoute?.settings?.name}', | ||
158 | - args: newRoute?.settings?.arguments, | ||
159 | - // previousArgs: newRoute?.settings?.arguments, | ||
160 | - isSnackbar: false, | ||
161 | - isBottomSheet: false, | ||
162 | - isDialog: false, | ||
163 | - ); | ||
164 | - | ||
165 | - if (routing != null) { | ||
166 | - routing(routeSend); | ||
167 | - } | ||
168 | - GetConfig.currentRoute = current; | ||
169 | - Get.setRouting(routeSend); | 116 | + print("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}"); |
117 | + if (GetConfig.isLogEnable) | ||
118 | + print("[GETX] NEW ROUTE ${newRoute?.settings?.name}"); | ||
119 | + | ||
120 | + _routeSend.update((value) { | ||
121 | + if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}'; | ||
122 | + value.args = newRoute?.settings?.arguments; | ||
123 | + value.route = newRoute; | ||
124 | + value.isBack = false; | ||
125 | + value.removed = ''; | ||
126 | + value.previous = '${oldRoute?.settings?.name}'; | ||
127 | + value.isSnackbar = false; | ||
128 | + value.isBottomSheet = false; | ||
129 | + value.isDialog = false; | ||
130 | + }); | ||
131 | + if (routing != null) routing(_routeSend); | ||
170 | } | 132 | } |
171 | 133 | ||
172 | @override | 134 | @override |
173 | void didRemove(Route route, Route previousRoute) { | 135 | void didRemove(Route route, Route previousRoute) { |
174 | super.didRemove(route, previousRoute); | 136 | super.didRemove(route, previousRoute); |
175 | if (GetConfig.isLogEnable) | 137 | if (GetConfig.isLogEnable) |
176 | - print("[REMOVING ROUTE] ${route?.settings?.name}"); | ||
177 | - | ||
178 | - if (GetConfig.smartManagement == SmartManagement.full) { | ||
179 | - GetInstance().removeDependencyByRoute("${route?.settings?.name}"); | ||
180 | - } | ||
181 | - | ||
182 | - final routeSend = Routing( | ||
183 | - isBack: false, | ||
184 | - route: previousRoute, | ||
185 | - // current: '${previousRoute?.settings?.name}', | ||
186 | - current: current, | ||
187 | - args: args, | ||
188 | - removed: '${route?.settings?.name}', | ||
189 | - // args: previousRoute?.settings?.arguments, | ||
190 | - isSnackbar: isSnackbar, | ||
191 | - isBottomSheet: isBottomSheet, | ||
192 | - isDialog: isDialog, | ||
193 | - // previousArgs: route?.settings?.arguments, | ||
194 | - ); | ||
195 | - | ||
196 | - if (routing != null) { | ||
197 | - routing(routeSend); | ||
198 | - } | ||
199 | - GetConfig.currentRoute = current; | ||
200 | - Get.setRouting(routeSend); | 138 | + print("[GETX] REMOVING ROUTE ${route?.settings?.name}"); |
139 | + | ||
140 | + _routeSend.update((value) { | ||
141 | + value.route = previousRoute; | ||
142 | + value.isBack = false; | ||
143 | + value.removed = '${route?.settings?.name}'; | ||
144 | + value.previous = '${route?.settings?.name}'; | ||
145 | + }); | ||
146 | + if (routing != null) routing(_routeSend); | ||
201 | } | 147 | } |
202 | } | 148 | } |
1 | +import 'dart:async'; | ||
1 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
2 | import 'rx_interface.dart'; | 3 | import 'rx_interface.dart'; |
3 | import 'utils/debouncer.dart'; | 4 | import 'utils/debouncer.dart'; |
4 | 5 | ||
5 | -void ever(RxInterface listener, Function(dynamic) callback, | 6 | +Worker ever(RxInterface listener, Function(dynamic) callback, |
6 | {bool condition = true}) { | 7 | {bool condition = true}) { |
7 | - listener.subject.stream.listen((event) { | ||
8 | - if (condition) { | ||
9 | - callback(event); | ||
10 | - } | 8 | + StreamSubscription sub = listener.subject.stream.listen((event) { |
9 | + if (condition) callback(event); | ||
11 | }); | 10 | }); |
11 | + | ||
12 | + Future<void> cancel() { | ||
13 | + return sub.cancel(); | ||
14 | + } | ||
15 | + | ||
16 | + return Worker(cancel, '[ever]'); | ||
12 | } | 17 | } |
13 | 18 | ||
14 | -void once(RxInterface listener, Function(dynamic) callback, | 19 | +Worker everAll(List<RxInterface> listener, Function(dynamic) callback, |
15 | {bool condition = true}) { | 20 | {bool condition = true}) { |
21 | + List<StreamSubscription> evers = <StreamSubscription>[]; | ||
22 | + | ||
23 | + for (var i in listener) { | ||
24 | + StreamSubscription sub = i.subject.stream.listen((event) { | ||
25 | + if (condition) callback(event); | ||
26 | + }); | ||
27 | + evers.add(sub); | ||
28 | + } | ||
29 | + | ||
30 | + Future<void> cancel() { | ||
31 | + for (var i in evers) { | ||
32 | + i.cancel(); | ||
33 | + } | ||
34 | + return Future.value(() {}); | ||
35 | + } | ||
36 | + | ||
37 | + return Worker(cancel, '[everAll]'); | ||
38 | +} | ||
39 | + | ||
40 | +Worker once(RxInterface listener, Function(dynamic) callback, | ||
41 | + {bool condition = true}) { | ||
42 | + StreamSubscription sub; | ||
16 | int times = 0; | 43 | int times = 0; |
17 | - listener.subject.stream.listen((event) { | 44 | + |
45 | + sub = listener.subject.stream.listen((event) { | ||
18 | if (!condition) return null; | 46 | if (!condition) return null; |
19 | times++; | 47 | times++; |
20 | if (times < 2) { | 48 | if (times < 2) { |
21 | callback(event); | 49 | callback(event); |
50 | + } else { | ||
51 | + sub.cancel(); | ||
22 | } | 52 | } |
23 | }); | 53 | }); |
54 | + | ||
55 | + Future<void> cancel() { | ||
56 | + return sub.cancel(); | ||
57 | + } | ||
58 | + | ||
59 | + return Worker(cancel, '[once]'); | ||
24 | } | 60 | } |
25 | 61 | ||
26 | -void interval(RxInterface listener, Function(dynamic) callback, | 62 | +Worker interval(RxInterface listener, Function(dynamic) callback, |
27 | {Duration time, bool condition = true}) { | 63 | {Duration time, bool condition = true}) { |
28 | bool debounceActive = false; | 64 | bool debounceActive = false; |
29 | - listener.subject.stream.listen((event) async { | 65 | + StreamSubscription sub = listener.subject.stream.listen((event) async { |
30 | if (debounceActive || !condition) return null; | 66 | if (debounceActive || !condition) return null; |
31 | debounceActive = true; | 67 | debounceActive = true; |
32 | await Future.delayed(time ?? Duration(seconds: 1)); | 68 | await Future.delayed(time ?? Duration(seconds: 1)); |
33 | debounceActive = false; | 69 | debounceActive = false; |
34 | callback(event); | 70 | callback(event); |
35 | }); | 71 | }); |
72 | + | ||
73 | + Future<void> cancel() { | ||
74 | + return sub.cancel(); | ||
75 | + } | ||
76 | + | ||
77 | + return Worker(cancel, '[interval]'); | ||
36 | } | 78 | } |
37 | 79 | ||
38 | -void debounce(RxInterface listener, Function(dynamic) callback, | 80 | +Worker debounce(RxInterface listener, Function(dynamic) callback, |
39 | {Duration time}) { | 81 | {Duration time}) { |
40 | final _debouncer = Debouncer(delay: time ?? Duration(milliseconds: 800)); | 82 | final _debouncer = Debouncer(delay: time ?? Duration(milliseconds: 800)); |
41 | - listener.subject.stream.listen((event) { | 83 | + StreamSubscription sub = listener.subject.stream.listen((event) { |
42 | _debouncer(() { | 84 | _debouncer(() { |
43 | callback(event); | 85 | callback(event); |
44 | }); | 86 | }); |
45 | }); | 87 | }); |
88 | + | ||
89 | + Future<void> cancel() { | ||
90 | + return sub.cancel(); | ||
91 | + } | ||
92 | + | ||
93 | + return Worker(cancel, '[debounce]'); | ||
94 | +} | ||
95 | + | ||
96 | +class Worker { | ||
97 | + Worker(this.worker, this.type); | ||
98 | + | ||
99 | + final Future<void> Function() worker; | ||
100 | + final String type; | ||
101 | + | ||
102 | + void _message() { | ||
103 | + if (GetConfig.isLogEnable) print('[Getx] Worker $type disposed'); | ||
104 | + } | ||
105 | + | ||
106 | + void dispose() { | ||
107 | + worker(); | ||
108 | + _message(); | ||
109 | + } | ||
110 | + | ||
111 | + void call() { | ||
112 | + worker(); | ||
113 | + _message(); | ||
114 | + } | ||
46 | } | 115 | } |
1 | +import 'dart:async'; | ||
2 | + | ||
1 | import 'package:flutter/widgets.dart'; | 3 | import 'package:flutter/widgets.dart'; |
2 | import 'package:get/src/instance/get_instance.dart'; | 4 | import 'package:get/src/instance/get_instance.dart'; |
3 | import 'package:get/src/root/smart_management.dart'; | 5 | import 'package:get/src/root/smart_management.dart'; |
@@ -34,6 +36,7 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | @@ -34,6 +36,7 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | ||
34 | RxInterface _observer; | 36 | RxInterface _observer; |
35 | T controller; | 37 | T controller; |
36 | bool isCreator = false; | 38 | bool isCreator = false; |
39 | + StreamSubscription subs; | ||
37 | 40 | ||
38 | @override | 41 | @override |
39 | void initState() { | 42 | void initState() { |
@@ -60,10 +63,10 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | @@ -60,10 +63,10 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | ||
60 | controller?.onStart(); | 63 | controller?.onStart(); |
61 | } | 64 | } |
62 | if (widget.initState != null) widget.initState(this); | 65 | if (widget.initState != null) widget.initState(this); |
63 | - if (isCreator && GetConfig.smartManagement == SmartManagement.onlyBuilder) { | ||
64 | - controller?.onStart(); | ||
65 | - } | ||
66 | - _observer.subject.stream.listen((data) => setState(() {})); | 66 | + // if (isCreator && GetConfig.smartManagement == SmartManagement.onlyBuilder) { |
67 | + // controller?.onStart(); | ||
68 | + // } | ||
69 | + subs = _observer.subject.stream.listen((data) => setState(() {})); | ||
67 | super.initState(); | 70 | super.initState(); |
68 | } | 71 | } |
69 | 72 | ||
@@ -89,7 +92,7 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | @@ -89,7 +92,7 @@ class GetImplXState<T extends DisposableInterface> extends State<GetX<T>> { | ||
89 | GetInstance().delete<T>(); | 92 | GetInstance().delete<T>(); |
90 | } | 93 | } |
91 | } | 94 | } |
92 | - | 95 | + subs.cancel(); |
93 | _observer.close(); | 96 | _observer.close(); |
94 | controller = null; | 97 | controller = null; |
95 | isCreator = null; | 98 | isCreator = null; |
@@ -66,6 +66,7 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -66,6 +66,7 @@ class _RxImpl<T> implements RxInterface<T> { | ||
66 | stream.listen(onData, onError: onError, onDone: onDone); | 66 | stream.listen(onData, onError: onError, onDone: onDone); |
67 | 67 | ||
68 | void bindStream(Stream<T> stream) => stream.listen((va) => value = va); | 68 | void bindStream(Stream<T> stream) => stream.listen((va) => value = va); |
69 | + | ||
69 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); | 70 | Stream<R> map<R>(R mapper(T data)) => stream.map(mapper); |
70 | } | 71 | } |
71 | 72 |
@@ -65,7 +65,7 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> { | @@ -65,7 +65,7 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> { | ||
65 | @override | 65 | @override |
66 | void initState() { | 66 | void initState() { |
67 | super.initState(); | 67 | super.initState(); |
68 | - | 68 | + if (widget.initState != null) widget.initState(this); |
69 | if (widget.global) { | 69 | if (widget.global) { |
70 | final isPrepared = GetInstance().isPrepared<T>(tag: widget.tag); | 70 | final isPrepared = GetInstance().isPrepared<T>(tag: widget.tag); |
71 | final isRegistred = GetInstance().isRegistred<T>(tag: widget.tag); | 71 | final isRegistred = GetInstance().isRegistred<T>(tag: widget.tag); |
@@ -96,7 +96,7 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> { | @@ -96,7 +96,7 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> { | ||
96 | controller._updaters.add(real); | 96 | controller._updaters.add(real); |
97 | controller?.onStart(); | 97 | controller?.onStart(); |
98 | } | 98 | } |
99 | - if (widget.initState != null) widget.initState(this); | 99 | + |
100 | if (isCreator && GetConfig.smartManagement == SmartManagement.onlyBuilder) { | 100 | if (isCreator && GetConfig.smartManagement == SmartManagement.onlyBuilder) { |
101 | controller?.onStart(); | 101 | controller?.onStart(); |
102 | } | 102 | } |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. |
3 | -version: 3.3.0 | 3 | +version: 3.4.0 |
4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment