added PageBindings that references GetPageRoute in [dependencies] method
Showing
3 changed files
with
16 additions
and
13 deletions
1 | +import '../../get_navigation/src/routes/default_route.dart'; | ||
2 | + | ||
1 | import 'get_instance.dart'; | 3 | import 'get_instance.dart'; |
2 | 4 | ||
3 | /// [Bindings] should be extended or implemented. | 5 | /// [Bindings] should be extended or implemented. |
@@ -10,6 +12,11 @@ abstract class Bindings { | @@ -10,6 +12,11 @@ abstract class Bindings { | ||
10 | void dependencies(); | 12 | void dependencies(); |
11 | } | 13 | } |
12 | 14 | ||
15 | +abstract class PageBindings extends Bindings { | ||
16 | + @override | ||
17 | + void dependencies([GetPageRoute? page]); | ||
18 | +} | ||
19 | + | ||
13 | /// Simplifies Bindings generation from a single callback. | 20 | /// Simplifies Bindings generation from a single callback. |
14 | /// To avoid the creation of a custom Binding instance per route. | 21 | /// To avoid the creation of a custom Binding instance per route. |
15 | /// | 22 | /// |
@@ -299,14 +299,6 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | @@ -299,14 +299,6 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | ||
299 | ); | 299 | ); |
300 | } | 300 | } |
301 | 301 | ||
302 | - // @override | ||
303 | - // Future<void> setInitialRoutePath(GetNavConfig configuration) async { | ||
304 | - // //no need to clear history with Reorder route strategy | ||
305 | - // // _unsafeHistoryClear(); | ||
306 | - // // _resultCompleter.clear(); | ||
307 | - // await pushHistory(configuration); | ||
308 | - // } | ||
309 | - | ||
310 | @override | 302 | @override |
311 | Future<void> setNewRoutePath(GetNavConfig configuration) async { | 303 | Future<void> setNewRoutePath(GetNavConfig configuration) async { |
312 | await pushHistory(configuration); | 304 | await pushHistory(configuration); |
@@ -89,11 +89,15 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | @@ -89,11 +89,15 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> { | ||
89 | Widget buildContent(BuildContext context) { | 89 | Widget buildContent(BuildContext context) { |
90 | final middlewareRunner = MiddlewareRunner(middlewares); | 90 | final middlewareRunner = MiddlewareRunner(middlewares); |
91 | final bindingsToBind = middlewareRunner.runOnBindingsStart(bindings); | 91 | final bindingsToBind = middlewareRunner.runOnBindingsStart(bindings); |
92 | - | ||
93 | - binding?.dependencies(); | ||
94 | - if (bindingsToBind != null) { | ||
95 | - for (final binding in bindingsToBind) { | ||
96 | - binding.dependencies(); | 92 | + final _bindingList = [ |
93 | + if (binding != null) binding!, | ||
94 | + ...?bindingsToBind, | ||
95 | + ]; | ||
96 | + for (var _b in _bindingList) { | ||
97 | + if (_b is PageBindings) { | ||
98 | + _b.dependencies(this); | ||
99 | + } else { | ||
100 | + _b.dependencies(); | ||
97 | } | 101 | } |
98 | } | 102 | } |
99 | 103 |
-
Please register or login to post a comment