Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit d1d75cf

Browse files
authored
Merge pull request #146 from Unity-Technologies/zgh/fix/navigation
fix navigation error
2 parents 1f3ff7e + 6e70612 commit d1d75cf

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

com.unity.uiwidgets/Runtime/widgets/navigator.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ public static Future<T> pushReplacementNamed<T,TO>(BuildContext context, string
541541
return of(context).pushReplacementNamed<T,TO>(routeName, arguments: arguments,result: result);
542542
}
543543

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+
544549
public static Future<T> popAndPushNamed<T,TO>(BuildContext context, string routeName,
545550
TO result = default,
546551
object arguments = null) {
@@ -1709,6 +1714,15 @@ public Future<T> pushReplacementNamed<T, TO>(
17091714
return pushReplacement<T, TO>(_routeNamed<T>(routeName, arguments: arguments), result: result);
17101715
}
17111716

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+
17121726
public Future<T> popAndPushNamed<T, TO>(
17131727
string routeName,
17141728
TO result = default,
@@ -1832,6 +1846,42 @@ public Future<T> pushReplacement<T, TO>(Route<T> newRoute, TO result) {
18321846
return newRoute.popped.to<T>();
18331847
}
18341848

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+
18351885
public Future<T> pushAndRemoveUntil<T>(Route<T> newRoute, RoutePredicate predicate) {
18361886
D.assert(!_debugLocked);
18371887
D.assert(() => {

0 commit comments

Comments
 (0)