From fd744a1244a8b9aa26b9b654ae07d21bbc08c379 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 17 Jul 2015 09:05:46 -0700 Subject: [PATCH] Use unique integers as the key for history items to prevent collisions --- packages/flutter/lib/widgets/navigator.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/flutter/lib/widgets/navigator.dart b/packages/flutter/lib/widgets/navigator.dart index 03d8c3bf91..99b5b87171 100644 --- a/packages/flutter/lib/widgets/navigator.dart +++ b/packages/flutter/lib/widgets/navigator.dart @@ -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 history = new List(); int historyIndex = 0; + int _lastKey = 0; Map namedRoutes = new Map(); 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),