Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
fd744a12
Commit
fd744a12
authored
Jul 17, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use unique integers as the key for history items to prevent collisions
parent
99346d00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
navigator.dart
packages/flutter/lib/widgets/navigator.dart
+6
-5
No files found.
packages/flutter/lib/widgets/navigator.dart
View file @
fd744a12
...
@@ -130,8 +130,9 @@ class Transition extends AnimatedComponent {
...
@@ -130,8 +130,9 @@ class Transition extends AnimatedComponent {
}
}
class
HistoryEntry
{
class
HistoryEntry
{
HistoryEntry
(
this
.
route
);
HistoryEntry
(
{
this
.
route
,
this
.
key
}
);
final
RouteBase
route
;
final
RouteBase
route
;
final
int
key
;
// TODO(jackson): Keep track of the requested transition
// TODO(jackson): Keep track of the requested transition
}
}
...
@@ -142,11 +143,12 @@ class NavigationState {
...
@@ -142,11 +143,12 @@ class NavigationState {
if
(
route
.
name
!=
null
)
if
(
route
.
name
!=
null
)
namedRoutes
[
route
.
name
]
=
route
;
namedRoutes
[
route
.
name
]
=
route
;
}
}
history
.
add
(
new
HistoryEntry
(
route
s
[
0
]
));
history
.
add
(
new
HistoryEntry
(
route
:
routes
[
0
],
key:
_lastKey
++
));
}
}
List
<
HistoryEntry
>
history
=
new
List
<
HistoryEntry
>();
List
<
HistoryEntry
>
history
=
new
List
<
HistoryEntry
>();
int
historyIndex
=
0
;
int
historyIndex
=
0
;
int
_lastKey
=
0
;
Map
<
String
,
RouteBase
>
namedRoutes
=
new
Map
<
String
,
RouteBase
>();
Map
<
String
,
RouteBase
>
namedRoutes
=
new
Map
<
String
,
RouteBase
>();
RouteBase
get
currentRoute
=>
history
[
historyIndex
].
route
;
RouteBase
get
currentRoute
=>
history
[
historyIndex
].
route
;
...
@@ -159,7 +161,7 @@ class NavigationState {
...
@@ -159,7 +161,7 @@ class NavigationState {
}
}
void
push
(
RouteBase
route
)
{
void
push
(
RouteBase
route
)
{
HistoryEntry
historyEntry
=
new
HistoryEntry
(
route
);
HistoryEntry
historyEntry
=
new
HistoryEntry
(
route
:
route
,
key:
_lastKey
++
);
history
.
insert
(
historyIndex
+
1
,
historyEntry
);
history
.
insert
(
historyIndex
+
1
,
historyEntry
);
historyIndex
++;
historyIndex
++;
}
}
...
@@ -224,9 +226,8 @@ class Navigator extends StatefulComponent {
...
@@ -224,9 +226,8 @@ class Navigator extends StatefulComponent {
}
}
if
(
content
==
null
)
if
(
content
==
null
)
continue
;
continue
;
String
key
=
historyEntry
.
route
.
key
;
Transition
transition
=
new
Transition
(
Transition
transition
=
new
Transition
(
key:
key
,
key:
historyEntry
.
key
.
toString
()
,
content:
content
,
content:
content
,
direction:
(
i
<=
state
.
historyIndex
)
?
TransitionDirection
.
forward
:
TransitionDirection
.
reverse
,
direction:
(
i
<=
state
.
historyIndex
)
?
TransitionDirection
.
forward
:
TransitionDirection
.
reverse
,
interactive:
(
i
==
state
.
historyIndex
),
interactive:
(
i
==
state
.
historyIndex
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment