Showing
3 changed files
with
19 additions
and
9 deletions
@@ -16,6 +16,7 @@ import '../../utils.dart'; | @@ -16,6 +16,7 @@ import '../../utils.dart'; | ||
16 | abstract class GetInterface { | 16 | abstract class GetInterface { |
17 | bool defaultPopGesture = GetPlatform.isIOS; | 17 | bool defaultPopGesture = GetPlatform.isIOS; |
18 | bool defaultOpaqueRoute = true; | 18 | bool defaultOpaqueRoute = true; |
19 | + bool forceRouteName = true; | ||
19 | Transition defaultTransition; | 20 | Transition defaultTransition; |
20 | Duration defaultDurationTransition = Duration(milliseconds: 400); | 21 | Duration defaultDurationTransition = Duration(milliseconds: 400); |
21 | bool defaultGlobalState = true; | 22 | bool defaultGlobalState = true; |
@@ -43,10 +43,12 @@ extension GetNavigation on GetInterface { | @@ -43,10 +43,12 @@ extension GetNavigation on GetInterface { | ||
43 | bool fullscreenDialog = false, | 43 | bool fullscreenDialog = false, |
44 | Object arguments, | 44 | Object arguments, |
45 | Bindings binding, | 45 | Bindings binding, |
46 | - preventDuplicates = true, | 46 | + bool preventDuplicates = true, |
47 | bool popGesture, | 47 | bool popGesture, |
48 | }) { | 48 | }) { |
49 | - if (preventDuplicates && '/${page.runtimeType}' == currentRoute) { | 49 | + if (preventDuplicates && |
50 | + '/${page.runtimeType}' == currentRoute && | ||
51 | + forceRouteName) { | ||
50 | return null; | 52 | return null; |
51 | } | 53 | } |
52 | return global(id).currentState.push( | 54 | return global(id).currentState.push( |
@@ -54,7 +56,7 @@ extension GetNavigation on GetInterface { | @@ -54,7 +56,7 @@ extension GetNavigation on GetInterface { | ||
54 | opaque: opaque ?? true, | 56 | opaque: opaque ?? true, |
55 | page: () => page, | 57 | page: () => page, |
56 | settings: RouteSettings( | 58 | settings: RouteSettings( |
57 | - name: '/${page.runtimeType}', | 59 | + name: forceRouteName ? '/${page.runtimeType}' : '', |
58 | arguments: arguments, | 60 | arguments: arguments, |
59 | ), | 61 | ), |
60 | popGesture: popGesture ?? defaultPopGesture, | 62 | popGesture: popGesture ?? defaultPopGesture, |
@@ -318,15 +320,18 @@ extension GetNavigation on GetInterface { | @@ -318,15 +320,18 @@ extension GetNavigation on GetInterface { | ||
318 | preventDuplicates = true, | 320 | preventDuplicates = true, |
319 | Duration duration, | 321 | Duration duration, |
320 | }) { | 322 | }) { |
321 | - if (preventDuplicates && '/${page.runtimeType}' == currentRoute) { | 323 | + if (preventDuplicates && |
324 | + '/${page.runtimeType}' == currentRoute && | ||
325 | + forceRouteName) { | ||
322 | return null; | 326 | return null; |
323 | } | 327 | } |
324 | return global(id).currentState.pushReplacement(GetPageRoute( | 328 | return global(id).currentState.pushReplacement(GetPageRoute( |
325 | opaque: opaque ?? true, | 329 | opaque: opaque ?? true, |
326 | page: () => page, | 330 | page: () => page, |
327 | binding: binding, | 331 | binding: binding, |
328 | - settings: | ||
329 | - RouteSettings(name: '/${page.runtimeType}', arguments: arguments), | 332 | + settings: RouteSettings( |
333 | + name: forceRouteName ? '/${page.runtimeType}' : '', | ||
334 | + arguments: arguments), | ||
330 | fullscreenDialog: fullscreenDialog, | 335 | fullscreenDialog: fullscreenDialog, |
331 | popGesture: popGesture ?? defaultPopGesture, | 336 | popGesture: popGesture ?? defaultPopGesture, |
332 | transition: transition ?? defaultTransition, | 337 | transition: transition ?? defaultTransition, |
@@ -381,8 +386,9 @@ extension GetNavigation on GetInterface { | @@ -381,8 +386,9 @@ extension GetNavigation on GetInterface { | ||
381 | popGesture: popGesture ?? defaultPopGesture, | 386 | popGesture: popGesture ?? defaultPopGesture, |
382 | page: () => page, | 387 | page: () => page, |
383 | binding: binding, | 388 | binding: binding, |
384 | - settings: | ||
385 | - RouteSettings(name: '/${page.runtimeType}', arguments: arguments), | 389 | + settings: RouteSettings( |
390 | + name: forceRouteName ? '/${page.runtimeType}' : '', | ||
391 | + arguments: arguments), | ||
386 | fullscreenDialog: fullscreenDialog, | 392 | fullscreenDialog: fullscreenDialog, |
387 | transition: transition ?? defaultTransition, | 393 | transition: transition ?? defaultTransition, |
388 | transitionDuration: duration ?? defaultDurationTransition, | 394 | transitionDuration: duration ?? defaultDurationTransition, |
@@ -50,6 +50,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -50,6 +50,7 @@ class GetMaterialApp extends StatelessWidget { | ||
50 | this.defaultTransition, | 50 | this.defaultTransition, |
51 | // this.actions, | 51 | // this.actions, |
52 | this.getPages, | 52 | this.getPages, |
53 | + this.forceRouteName = true, | ||
53 | this.opaqueRoute, | 54 | this.opaqueRoute, |
54 | this.enableLog, | 55 | this.enableLog, |
55 | this.logWriterCallback, | 56 | this.logWriterCallback, |
@@ -102,6 +103,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -102,6 +103,7 @@ class GetMaterialApp extends StatelessWidget { | ||
102 | final Function(Routing) routingCallback; | 103 | final Function(Routing) routingCallback; |
103 | final Transition defaultTransition; | 104 | final Transition defaultTransition; |
104 | final bool opaqueRoute; | 105 | final bool opaqueRoute; |
106 | + final bool forceRouteName; | ||
105 | final VoidCallback onInit; | 107 | final VoidCallback onInit; |
106 | final VoidCallback onDispose; | 108 | final VoidCallback onDispose; |
107 | final bool enableLog; | 109 | final bool enableLog; |
@@ -189,6 +191,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -189,6 +191,8 @@ class GetMaterialApp extends StatelessWidget { | ||
189 | 191 | ||
190 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; | 192 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; |
191 | 193 | ||
194 | + Get.forceRouteName = forceRouteName; | ||
195 | + | ||
192 | if (translations != null) { | 196 | if (translations != null) { |
193 | Get.translations = translations.keys; | 197 | Get.translations = translations.keys; |
194 | } else if (translationsKeys != null) { | 198 | } else if (translationsKeys != null) { |
@@ -261,7 +265,6 @@ abstract class Translations { | @@ -261,7 +265,6 @@ abstract class Translations { | ||
261 | Map<String, Map<String, String>> get keys; | 265 | Map<String, Map<String, String>> get keys; |
262 | } | 266 | } |
263 | 267 | ||
264 | - | ||
265 | extension Trans on String { | 268 | extension Trans on String { |
266 | String get tr { | 269 | String get tr { |
267 | // Returns the key if locale is null. | 270 | // Returns the key if locale is null. |
-
Please register or login to post a comment