@@ -541,6 +541,11 @@ public static Future<T> pushReplacementNamed<T,TO>(BuildContext context, string
541
541
return of ( context ) . pushReplacementNamed < T , TO > ( routeName , arguments : arguments , result : result ) ;
542
542
}
543
543
544
+ public static Future pushReplacementNamed ( BuildContext context , string routeName ,
545
+ object result = default , object arguments = null ) {
546
+ return of ( context ) . pushReplacementNamed ( routeName , arguments : arguments , result : result ) ;
547
+ }
548
+
544
549
public static Future < T > popAndPushNamed < T , TO > ( BuildContext context , string routeName ,
545
550
TO result = default ,
546
551
object arguments = null ) {
@@ -1709,6 +1714,15 @@ public Future<T> pushReplacementNamed<T, TO>(
1709
1714
return pushReplacement < T , TO > ( _routeNamed < T > ( routeName , arguments : arguments ) , result : result ) ;
1710
1715
}
1711
1716
1717
+ public Future pushReplacementNamed (
1718
+ string routeName ,
1719
+ object result = default ,
1720
+ object arguments = null
1721
+ ) {
1722
+ return pushReplacement ( _routeNamed ( routeName , arguments : arguments ) , result : result ) ;
1723
+ }
1724
+
1725
+
1712
1726
public Future < T > popAndPushNamed < T , TO > (
1713
1727
string routeName ,
1714
1728
TO result = default ,
@@ -1832,6 +1846,42 @@ public Future<T> pushReplacement<T, TO>(Route<T> newRoute, TO result) {
1832
1846
return newRoute . popped . to < T > ( ) ;
1833
1847
}
1834
1848
1849
+ public Future pushReplacement ( Route newRoute , object result ) {
1850
+ D . assert ( ! _debugLocked ) ;
1851
+ D . assert ( ( ) => {
1852
+ _debugLocked = true ;
1853
+ return true ;
1854
+ } ) ;
1855
+ D . assert ( newRoute != null ) ;
1856
+ D . assert ( newRoute . _navigator == null ) ;
1857
+ D . assert ( _history . isNotEmpty ( ) ) ;
1858
+
1859
+ bool anyEntry = false ;
1860
+ foreach ( var historyEntry in _history ) {
1861
+ if ( _RouteEntry . isPresentPredicate ( historyEntry ) ) {
1862
+ anyEntry = true ;
1863
+ }
1864
+ }
1865
+ D . assert ( anyEntry , ( ) => "Navigator has no active routes to replace." ) ;
1866
+ _RouteEntry lastEntry = null ;
1867
+ foreach ( var historyEntry in _history ) {
1868
+ if ( _RouteEntry . isPresentPredicate ( historyEntry ) ) {
1869
+ lastEntry = historyEntry ;
1870
+ }
1871
+ }
1872
+ lastEntry . complete ( result , isReplaced : true ) ;
1873
+
1874
+ _history . Add ( new _RouteEntry ( newRoute , initialState : _RouteLifecycle . pushReplace ) ) ;
1875
+ _flushHistoryUpdates ( ) ;
1876
+ D . assert ( ( ) => {
1877
+ _debugLocked = false ;
1878
+ return true ;
1879
+ } ) ;
1880
+ _afterNavigation ( newRoute ) ;
1881
+ return newRoute . popped . to < object > ( ) ;
1882
+ }
1883
+
1884
+
1835
1885
public Future < T > pushAndRemoveUntil < T > ( Route < T > newRoute , RoutePredicate predicate ) {
1836
1886
D . assert ( ! _debugLocked ) ;
1837
1887
D . assert ( ( ) => {
0 commit comments