Skip to content

Commit bb77838

Browse files
committed
fix replaceNamed
1 parent 7d1a3f1 commit bb77838

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

flutter_modular/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## [4.1.1] - 2021-10-04
1+
## [4.1.2] - 2021-10-08
22
* Added "maintainState" in routes. [#572](https://github.com/Flutterando/modular/issues/572)
3+
* Fixed pushReplacementNamed
34

45
## [4.1.0+1] - 2021-10-01
56
* Modular is now HOT-RELOAD friendly!

flutter_modular/lib/src/presenter/navigation/modular_router_delegate.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,14 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
180180
arguments: arguments, popCallback: popComplete.complete);
181181
final currentRoutes = [...currentConfiguration!.routes];
182182
if (forRoot) {
183-
currentRoutes.removeWhere((element) => element.schema != '');
184-
currentRoutes.removeLast();
185-
book = currentConfiguration!.copyWith(
186-
routes: [...currentRoutes, book.routes.first.copyWith(schema: '')]);
183+
//;currentRoutes.removeWhere((element) => element.schema != '');
184+
final indexLast =
185+
currentRoutes.lastIndexWhere((element) => element.schema == '');
186+
currentRoutes[indexLast] = book.routes.first.copyWith(schema: '');
187+
book = currentConfiguration!.copyWith(routes: [...currentRoutes]);
187188
await setNewRoutePath(book);
188189
} else {
189-
final list = [...currentConfiguration!.routes]..removeLast();
190+
final list = currentRoutes..removeLast();
190191

191192
for (var route in book.routes.reversed) {
192193
if (list

flutter_modular/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_modular
22
description: Smart project structure with dependency injection and route management
3-
version: 4.1.1
3+
version: 4.1.2
44
homepage: https://github.com/Flutterando/modular
55

66
environment:

0 commit comments

Comments
 (0)