提交 8b0c5d21 编写于 作者: C Collin Jackson

Use unique integers as the key for history items to prevent collisions

上级 9b304bbc
......@@ -130,8 +130,9 @@ class Transition extends AnimatedComponent {
}
class HistoryEntry {
HistoryEntry(this.route);
HistoryEntry({ this.route, this.key });
final RouteBase route;
final int key;
// TODO(jackson): Keep track of the requested transition
}
......@@ -142,11 +143,12 @@ class NavigationState {
if (route.name != null)
namedRoutes[route.name] = route;
}
history.add(new HistoryEntry(routes[0]));
history.add(new HistoryEntry(route: routes[0], key: _lastKey++));
}
List<HistoryEntry> history = new List<HistoryEntry>();
int historyIndex = 0;
int _lastKey = 0;
Map<String, RouteBase> namedRoutes = new Map<String, RouteBase>();
RouteBase get currentRoute => history[historyIndex].route;
......@@ -159,7 +161,7 @@ class NavigationState {
}
void push(RouteBase route) {
HistoryEntry historyEntry = new HistoryEntry(route);
HistoryEntry historyEntry = new HistoryEntry(route: route, key: _lastKey++);
history.insert(historyIndex + 1, historyEntry);
historyIndex++;
}
......@@ -224,9 +226,8 @@ class Navigator extends StatefulComponent {
}
if (content == null)
continue;
String key = historyEntry.route.key;
Transition transition = new Transition(
key: key,
key: historyEntry.key.toString(),
content: content,
direction: (i <= state.historyIndex) ? TransitionDirection.forward : TransitionDirection.reverse,
interactive: (i == state.historyIndex),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册