Ahmed Fwela

added PageBindings that references GetPageRoute in [dependencies] method

import '../../get_navigation/src/routes/default_route.dart';
import 'get_instance.dart';
/// [Bindings] should be extended or implemented.
... ... @@ -10,6 +12,11 @@ abstract class Bindings {
void dependencies();
}
abstract class PageBindings extends Bindings {
@override
void dependencies([GetPageRoute? page]);
}
/// Simplifies Bindings generation from a single callback.
/// To avoid the creation of a custom Binding instance per route.
///
... ...
... ... @@ -299,14 +299,6 @@ class GetDelegate extends RouterDelegate<GetNavConfig>
);
}
// @override
// Future<void> setInitialRoutePath(GetNavConfig configuration) async {
// //no need to clear history with Reorder route strategy
// // _unsafeHistoryClear();
// // _resultCompleter.clear();
// await pushHistory(configuration);
// }
@override
Future<void> setNewRoutePath(GetNavConfig configuration) async {
await pushHistory(configuration);
... ...
... ... @@ -89,11 +89,15 @@ class GetPageRoute<T> extends PageRoute<T> with GetPageRouteTransitionMixin<T> {
Widget buildContent(BuildContext context) {
final middlewareRunner = MiddlewareRunner(middlewares);
final bindingsToBind = middlewareRunner.runOnBindingsStart(bindings);
binding?.dependencies();
if (bindingsToBind != null) {
for (final binding in bindingsToBind) {
binding.dependencies();
final _bindingList = [
if (binding != null) binding!,
...?bindingsToBind,
];
for (var _b in _bindingList) {
if (_b is PageBindings) {
_b.dependencies(this);
} else {
_b.dependencies();
}
}
... ...