Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a19fdb4

Browse files
committed
Merge pull request #77 from collinjackson/fix_history
Fix history collisions R=abarth
2 parents 9b304bb + 8b0c5d2 commit a19fdb4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sky/sdk/lib/widgets/navigator.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ class Transition extends AnimatedComponent {
130130
}
131131

132132
class HistoryEntry {
133-
HistoryEntry(this.route);
133+
HistoryEntry({ this.route, this.key });
134134
final RouteBase route;
135+
final int key;
135136
// TODO(jackson): Keep track of the requested transition
136137
}
137138

@@ -142,11 +143,12 @@ class NavigationState {
142143
if (route.name != null)
143144
namedRoutes[route.name] = route;
144145
}
145-
history.add(new HistoryEntry(routes[0]));
146+
history.add(new HistoryEntry(route: routes[0], key: _lastKey++));
146147
}
147148

148149
List<HistoryEntry> history = new List<HistoryEntry>();
149150
int historyIndex = 0;
151+
int _lastKey = 0;
150152
Map<String, RouteBase> namedRoutes = new Map<String, RouteBase>();
151153

152154
RouteBase get currentRoute => history[historyIndex].route;
@@ -159,7 +161,7 @@ class NavigationState {
159161
}
160162

161163
void push(RouteBase route) {
162-
HistoryEntry historyEntry = new HistoryEntry(route);
164+
HistoryEntry historyEntry = new HistoryEntry(route: route, key: _lastKey++);
163165
history.insert(historyIndex + 1, historyEntry);
164166
historyIndex++;
165167
}
@@ -224,9 +226,8 @@ class Navigator extends StatefulComponent {
224226
}
225227
if (content == null)
226228
continue;
227-
String key = historyEntry.route.key;
228229
Transition transition = new Transition(
229-
key: key,
230+
key: historyEntry.key.toString(),
230231
content: content,
231232
direction: (i <= state.historyIndex) ? TransitionDirection.forward : TransitionDirection.reverse,
232233
interactive: (i == state.historyIndex),

0 commit comments

Comments
 (0)