Committed by
GitHub
Merge pull request #1676 from liasica/patch-1
Fix multiple middlewares redirect not working.
Showing
1 changed file
with
5 additions
and
4 deletions
| @@ -145,12 +145,13 @@ class MiddlewareRunner { | @@ -145,12 +145,13 @@ class MiddlewareRunner { | ||
| 145 | 145 | ||
| 146 | RouteSettings? runRedirect(String? route) { | 146 | RouteSettings? runRedirect(String? route) { | 
| 147 | RouteSettings? to; | 147 | RouteSettings? to; | 
| 148 | - _getMiddlewares().forEach((element) { | 148 | + for (final element in _getMiddlewares()) { | 
| 149 | to = element.redirect(route); | 149 | to = element.redirect(route); | 
| 150 | - }); | ||
| 151 | - if (to != null) { | ||
| 152 | - Get.log('Redirect to $to'); | 150 | + if (to != null) { | 
| 151 | + break; | ||
| 152 | + } | ||
| 153 | } | 153 | } | 
| 154 | + Get.log('Redirect to $to'); | ||
| 154 | return to; | 155 | return to; | 
| 155 | } | 156 | } | 
| 156 | 157 | 
- 
Please register or login to post a comment