Showing
4 changed files
with
34 additions
and
38 deletions
1 | +## [4.3.6] | ||
2 | +- Fix error with autodispose of additional dependencies beyond GetxController | ||
3 | +- Added ability to add your own delegate to RouterOutlet (@steven-spiel) | ||
4 | + | ||
1 | ## [4.3.5] | 5 | ## [4.3.5] |
2 | - Fix GetConnect timeout (@jasonlaw) | 6 | - Fix GetConnect timeout (@jasonlaw) |
3 | - Improve Vietnamese docs (@hp1909) | 7 | - Improve Vietnamese docs (@hp1909) |
@@ -7,7 +7,7 @@ import '../../get.dart'; | @@ -7,7 +7,7 @@ import '../../get.dart'; | ||
7 | class RouterReportManager<T> { | 7 | class RouterReportManager<T> { |
8 | /// Holds a reference to `Get.reference` when the Instance was | 8 | /// Holds a reference to `Get.reference` when the Instance was |
9 | /// created to manage the memory. | 9 | /// created to manage the memory. |
10 | - static final Map<Route?, String> _routesKey = {}; | 10 | + static final Map<Route?, List<String>> _routesKey = {}; |
11 | 11 | ||
12 | /// Stores the onClose() references of instances created with `Get.create()` | 12 | /// Stores the onClose() references of instances created with `Get.create()` |
13 | /// using the `Get.reference`. | 13 | /// using the `Get.reference`. |
@@ -29,7 +29,12 @@ class RouterReportManager<T> { | @@ -29,7 +29,12 @@ class RouterReportManager<T> { | ||
29 | /// Links a Class instance [S] (or [tag]) to the current route. | 29 | /// Links a Class instance [S] (or [tag]) to the current route. |
30 | /// Requires usage of `GetMaterialApp`. | 30 | /// Requires usage of `GetMaterialApp`. |
31 | static void reportDependencyLinkedToRoute(String depedencyKey) { | 31 | static void reportDependencyLinkedToRoute(String depedencyKey) { |
32 | - _routesKey[_current] = depedencyKey; | 32 | + if (_current == null) return; |
33 | + if (_routesKey.containsKey(_current)) { | ||
34 | + _routesKey[_current!]!.add(depedencyKey); | ||
35 | + } else { | ||
36 | + _routesKey[_current] = <String>[depedencyKey]; | ||
37 | + } | ||
33 | } | 38 | } |
34 | 39 | ||
35 | static void clearRouteKeys() { | 40 | static void clearRouteKeys() { |
@@ -46,9 +51,6 @@ class RouterReportManager<T> { | @@ -46,9 +51,6 @@ class RouterReportManager<T> { | ||
46 | static void reportRouteDispose(Route disposed) { | 51 | static void reportRouteDispose(Route disposed) { |
47 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 52 | if (Get.smartManagement != SmartManagement.onlyBuilder) { |
48 | WidgetsBinding.instance!.addPostFrameCallback((_) { | 53 | WidgetsBinding.instance!.addPostFrameCallback((_) { |
49 | - ///TODO: Check if it's necessary to compare _current != disposed | ||
50 | - ///Adding it breaks the context Navigation logic, | ||
51 | - ///as it resolves by Route name. | ||
52 | _removeDependencyByRoute(disposed); | 54 | _removeDependencyByRoute(disposed); |
53 | }); | 55 | }); |
54 | } | 56 | } |
@@ -56,11 +58,8 @@ class RouterReportManager<T> { | @@ -56,11 +58,8 @@ class RouterReportManager<T> { | ||
56 | 58 | ||
57 | static void reportRouteWillDispose(Route disposed) { | 59 | static void reportRouteWillDispose(Route disposed) { |
58 | final keysToRemove = <String>[]; | 60 | final keysToRemove = <String>[]; |
59 | - _routesKey.forEach((key, value) { | ||
60 | - if (key == disposed) { | ||
61 | - keysToRemove.add(value); | ||
62 | - } | ||
63 | - }); | 61 | + |
62 | + _routesKey[disposed]?.forEach(keysToRemove.add); | ||
64 | 63 | ||
65 | /// Removes `Get.create()` instances registered in `routeName`. | 64 | /// Removes `Get.create()` instances registered in `routeName`. |
66 | if (_routesByCreate.containsKey(disposed)) { | 65 | if (_routesByCreate.containsKey(disposed)) { |
@@ -88,11 +87,8 @@ class RouterReportManager<T> { | @@ -88,11 +87,8 @@ class RouterReportManager<T> { | ||
88 | /// Meant for internal usage of `GetPageRoute` and `GetDialogRoute` | 87 | /// Meant for internal usage of `GetPageRoute` and `GetDialogRoute` |
89 | static void _removeDependencyByRoute(Route routeName) { | 88 | static void _removeDependencyByRoute(Route routeName) { |
90 | final keysToRemove = <String>[]; | 89 | final keysToRemove = <String>[]; |
91 | - _routesKey.forEach((key, value) { | ||
92 | - if (key == routeName) { | ||
93 | - keysToRemove.add(value); | ||
94 | - } | ||
95 | - }); | 90 | + |
91 | + _routesKey[routeName]?.forEach(keysToRemove.add); | ||
96 | 92 | ||
97 | /// Removes `Get.create()` instances registered in `routeName`. | 93 | /// Removes `Get.create()` instances registered in `routeName`. |
98 | if (_routesByCreate.containsKey(routeName)) { | 94 | if (_routesByCreate.containsKey(routeName)) { |
@@ -108,7 +104,7 @@ class RouterReportManager<T> { | @@ -108,7 +104,7 @@ class RouterReportManager<T> { | ||
108 | for (final element in keysToRemove) { | 104 | for (final element in keysToRemove) { |
109 | final value = GetInstance().delete(key: element); | 105 | final value = GetInstance().delete(key: element); |
110 | if (value) { | 106 | if (value) { |
111 | - _routesKey.remove(element); | 107 | + _routesKey[routeName]?.remove(element); |
112 | } | 108 | } |
113 | } | 109 | } |
114 | 110 |
@@ -7,7 +7,22 @@ import 'get_transition_mixin.dart'; | @@ -7,7 +7,22 @@ import 'get_transition_mixin.dart'; | ||
7 | import 'route_middleware.dart'; | 7 | import 'route_middleware.dart'; |
8 | import 'transitions_type.dart'; | 8 | import 'transitions_type.dart'; |
9 | 9 | ||
10 | -class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | 10 | +mixin PageRouteReportMixin<T> on Route<T> { |
11 | + @override | ||
12 | + void install() { | ||
13 | + super.install(); | ||
14 | + RouterReportManager.reportCurrentRoute(this); | ||
15 | + } | ||
16 | + | ||
17 | + @override | ||
18 | + void dispose() { | ||
19 | + super.dispose(); | ||
20 | + RouterReportManager.reportRouteDispose(this); | ||
21 | + } | ||
22 | +} | ||
23 | + | ||
24 | +class GetPageRoute<T> extends PageRoute<T> | ||
25 | + with GetPageRouteTransitionMixin<T>, PageRouteReportMixin { | ||
11 | /// Creates a page route for use in an iOS designed app. | 26 | /// Creates a page route for use in an iOS designed app. |
12 | /// | 27 | /// |
13 | /// The [builder], [maintainState], and [fullscreenDialog] arguments must not | 28 | /// The [builder], [maintainState], and [fullscreenDialog] arguments must not |
@@ -35,11 +50,7 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | @@ -35,11 +50,7 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | ||
35 | this.maintainState = true, | 50 | this.maintainState = true, |
36 | bool fullscreenDialog = false, | 51 | bool fullscreenDialog = false, |
37 | this.middlewares, | 52 | this.middlewares, |
38 | - }) : super(settings: settings, fullscreenDialog: fullscreenDialog) { | ||
39 | - _bla = this; | ||
40 | - } | ||
41 | - | ||
42 | - late Route _bla; | 53 | + }) : super(settings: settings, fullscreenDialog: fullscreenDialog); |
43 | 54 | ||
44 | @override | 55 | @override |
45 | final Duration transitionDuration; | 56 | final Duration transitionDuration; |
@@ -75,23 +86,8 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | @@ -75,23 +86,8 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | ||
75 | final bool maintainState; | 86 | final bool maintainState; |
76 | 87 | ||
77 | @override | 88 | @override |
78 | - void install() { | ||
79 | - super.install(); | ||
80 | - RouterReportManager.reportCurrentRoute(this); | ||
81 | - } | ||
82 | - | ||
83 | - @override | ||
84 | void dispose() { | 89 | void dispose() { |
85 | super.dispose(); | 90 | super.dispose(); |
86 | - if (_bla != this) { | ||
87 | - throw 'DJHOSIDS'; | ||
88 | - } | ||
89 | - RouterReportManager.reportRouteDispose(this); | ||
90 | - | ||
91 | - // if (Get.smartManagement != SmartManagement.onlyBuilder) { | ||
92 | - // GetInstance().removeDependencyByRoute("$reference"); | ||
93 | - // } | ||
94 | - | ||
95 | final middlewareRunner = MiddlewareRunner(middlewares); | 91 | final middlewareRunner = MiddlewareRunner(middlewares); |
96 | middlewareRunner.runOnPageDispose(); | 92 | middlewareRunner.runOnPageDispose(); |
97 | } | 93 | } |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. |
3 | -version: 4.3.5 | 3 | +version: 4.3.6 |
4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment