@@ -28,7 +28,10 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
2828 final ReportPop reportPop;
2929 List <NavigatorObserver > observers = [];
3030
31- ModularRouterDelegate ({required this .parser, required this .navigatorKey, required this .reportPop});
31+ ModularRouterDelegate (
32+ {required this .parser,
33+ required this .navigatorKey,
34+ required this .reportPop});
3235
3336 @override
3437 ModularBook ? currentConfiguration;
@@ -67,8 +70,11 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
6770 Future <void > setNewRoutePath (ModularBook book) async {
6871 final disposableRoutes = < ParallelRoute > [];
6972
70- for (var route in currentConfiguration? .routes ?? < ParallelRoute <dynamic >> []) {
71- if (book.routes.indexWhere ((element) => element.uri.path == route.uri.path) == - 1 ) {
73+ for (var route
74+ in currentConfiguration? .routes ?? < ParallelRoute <dynamic >> []) {
75+ if (book.routes
76+ .indexWhere ((element) => element.uri.path == route.uri.path) ==
77+ - 1 ) {
7278 disposableRoutes.add (route);
7379 }
7480 }
@@ -80,7 +86,8 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
8086 reportPop.call (disposableRoute);
8187 }
8288
83- final arguments = parser.getArguments ().getOrElse ((l) => ModularArguments .empty ());
89+ final arguments =
90+ parser.getArguments ().getOrElse ((l) => ModularArguments .empty ());
8491 parser.setArguments (arguments.copyWith (params: {}, data: null ));
8592 }
8693
@@ -110,25 +117,36 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
110117 parallel.popCallback? .call (result);
111118 currentConfiguration? .routes.remove (parallel);
112119 reportPop.call (parallel);
113- final arguments = parser.getArguments ().getOrElse ((l) => ModularArguments .empty ());
120+ final arguments =
121+ parser.getArguments ().getOrElse ((l) => ModularArguments .empty ());
114122 parser.setArguments (arguments.copyWith (uri: currentConfiguration! .uri));
115123 notifyListeners ();
116124
117125 return true ;
118126 }
119127
120128 @override
121- Future <T ?> pushNamed <T extends Object ?>(String routeName, {Object ? arguments, bool forRoot = false }) async {
129+ Future <T ?> pushNamed <T extends Object ?>(String routeName,
130+ {Object ? arguments, bool forRoot = false }) async {
122131 final popComplete = Completer ();
123- var book = await parser.selectBook (routeName, arguments: arguments, popCallback: popComplete.complete);
132+ var book = await parser.selectBook (routeName,
133+ arguments: arguments, popCallback: popComplete.complete);
124134 if (forRoot) {
125- book = currentConfiguration! .copyWith (routes: [...currentConfiguration! .routes, book.routes.last.copyWith (schema: '' )]);
135+ book = currentConfiguration! .copyWith (routes: [
136+ ...currentConfiguration! .routes,
137+ book.routes.last.copyWith (schema: '' )
138+ ]);
126139 await setNewRoutePath (book);
127140 } else {
128141 final list = [...currentConfiguration! .routes];
129142
130143 for (var route in book.routes.reversed) {
131- if (list.firstWhere ((element) => element.uri.toString () == route.uri.toString (), orElse: () => ParallelRoute .empty ()).name == '' ) {
144+ if (list
145+ .firstWhere (
146+ (element) => element.uri.toString () == route.uri.toString (),
147+ orElse: () => ParallelRoute .empty ())
148+ .name ==
149+ '' ) {
132150 list.add (route);
133151 }
134152 }
@@ -144,20 +162,31 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
144162 }
145163
146164 @override
147- Future <T ?> pushReplacementNamed <T extends Object ?, TO extends Object ?>(String routeName, {TO ? result, Object ? arguments, bool forRoot = false }) async {
165+ Future <T ?> pushReplacementNamed <T extends Object ?, TO extends Object ?>(
166+ String routeName,
167+ {TO ? result,
168+ Object ? arguments,
169+ bool forRoot = false }) async {
148170 final popComplete = Completer ();
149- var book = await parser.selectBook (routeName, arguments: arguments, popCallback: popComplete.complete);
171+ var book = await parser.selectBook (routeName,
172+ arguments: arguments, popCallback: popComplete.complete);
150173 final currentRoutes = [...currentConfiguration! .routes];
151174 if (forRoot) {
152175 currentRoutes.removeWhere ((element) => element.schema != '' );
153176 currentRoutes.removeLast ();
154- book = currentConfiguration! .copyWith (routes: [...currentRoutes, book.routes.first.copyWith (schema: '' )]);
177+ book = currentConfiguration! .copyWith (
178+ routes: [...currentRoutes, book.routes.first.copyWith (schema: '' )]);
155179 await setNewRoutePath (book);
156180 } else {
157181 final list = [...currentConfiguration! .routes]..removeLast ();
158182
159183 for (var route in book.routes.reversed) {
160- if (list.firstWhere ((element) => element.uri.toString () == route.uri.toString (), orElse: () => ParallelRoute .empty ()).name == '' ) {
184+ if (list
185+ .firstWhere (
186+ (element) => element.uri.toString () == route.uri.toString (),
187+ orElse: () => ParallelRoute .empty ())
188+ .name ==
189+ '' ) {
161190 list.add (route);
162191 }
163192 }
@@ -168,7 +197,11 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
168197 }
169198
170199 @override
171- Future <T ?> popAndPushNamed <T extends Object ?, TO extends Object ?>(String routeName, {TO ? result, Object ? arguments, bool forRoot = false }) {
200+ Future <T ?> popAndPushNamed <T extends Object ?, TO extends Object ?>(
201+ String routeName,
202+ {TO ? result,
203+ Object ? arguments,
204+ bool forRoot = false }) {
172205 pop (result);
173206 return pushNamed (routeName, arguments: arguments);
174207 }
@@ -177,15 +210,20 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
177210 bool canPop () => navigatorKey.currentState? .canPop () ?? false ;
178211
179212 @override
180- Future <bool > maybePop <T extends Object ?>([T ? result]) => navigatorKey.currentState? .maybePop (result) ?? Future .value (false );
213+ Future <bool > maybePop <T extends Object ?>([T ? result]) =>
214+ navigatorKey.currentState? .maybePop (result) ?? Future .value (false );
181215
182216 @override
183- void pop <T extends Object ?>([T ? result]) => navigatorKey.currentState? .pop (result);
217+ void pop <T extends Object ?>([T ? result]) =>
218+ navigatorKey.currentState? .pop (result);
184219
185220 @override
186221 void popUntil (bool Function (Route ) predicate) {
187222 var isFoundedPages = currentConfiguration? .routes.where ((route) {
188- return predicate (CustomModalRoute (ModularPage (route: route, args: ModularArguments .empty (), flags: ModularFlags ())));
223+ return predicate (CustomModalRoute (ModularPage (
224+ route: route,
225+ args: ModularArguments .empty (),
226+ flags: ModularFlags ())));
189227 });
190228
191229 isFoundedPages ?? = [];
@@ -197,7 +235,9 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
197235 }
198236
199237 @override
200- Future <T ?> pushNamedAndRemoveUntil <T extends Object ?>(String newRouteName, bool Function (Route ) predicate, {Object ? arguments, bool forRoot = false }) {
238+ Future <T ?> pushNamedAndRemoveUntil <T extends Object ?>(
239+ String newRouteName, bool Function (Route ) predicate,
240+ {Object ? arguments, bool forRoot = false }) {
201241 popUntil (predicate);
202242 return pushNamed <T >(newRouteName, arguments: arguments, forRoot: forRoot);
203243 }
@@ -224,7 +264,8 @@ class CustomModalRoute extends ModalRoute {
224264 String ? get barrierLabel => throw UnimplementedError ();
225265
226266 @override
227- Widget buildPage (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation) {
267+ Widget buildPage (BuildContext context, Animation <double > animation,
268+ Animation <double > secondaryAnimation) {
228269 throw UnimplementedError ();
229270 }
230271
0 commit comments