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
e074af80
Commit
e074af80
authored
Mar 22, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2837 from HansMuller/overscroll
Fixed VirtualViewport child key assignment
parents
839334a5
ff424196
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
20 deletions
+28
-20
debug.dart
packages/flutter/lib/src/widgets/debug.dart
+22
-0
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+3
-19
virtual_viewport.dart
packages/flutter/lib/src/widgets/virtual_viewport.dart
+3
-1
No files found.
packages/flutter/lib/src/widgets/debug.dart
View file @
e074af80
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:collection'
;
import
'framework.dart'
;
import
'media_query.dart'
;
...
...
@@ -22,3 +24,23 @@ bool debugCheckHasMediaQuery(BuildContext context) {
});
return
true
;
}
bool
debugHasDuplicateKeys
(
Widget
parent
,
Iterable
<
Widget
>
children
)
{
assert
(()
{
Set
<
Key
>
keySet
=
new
HashSet
<
Key
>();
for
(
Widget
child
in
children
)
{
assert
(
child
!=
null
);
if
(
child
.
key
==
null
)
continue
;
if
(!
keySet
.
add
(
child
.
key
))
{
throw
new
FlutterError
(
'Duplicate keys found.
\n
'
'If multiple keyed nodes exist as children of another node, they must have unique keys.
\n
'
'
$parent
has multiple children with key "
${child.key}
".'
);
}
}
return
true
;
});
return
false
;
}
packages/flutter/lib/src/widgets/framework.dart
View file @
e074af80
...
...
@@ -5,6 +5,8 @@
import
'dart:async'
;
import
'dart:collection'
;
import
'debug.dart'
;
import
'package:flutter/rendering.dart'
;
export
'dart:ui'
show
hashValues
,
hashList
;
...
...
@@ -1935,7 +1937,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement {
/// Instantiation of RenderObjectWidgets that can have a list of children
class
MultiChildRenderObjectElement
extends
RenderObjectElement
{
MultiChildRenderObjectElement
(
MultiChildRenderObjectWidget
widget
)
:
super
(
widget
)
{
assert
(!
_debugHasDuplicateIds
(
));
assert
(!
debugHasDuplicateKeys
(
widget
,
widget
.
children
));
}
@override
...
...
@@ -1968,24 +1970,6 @@ class MultiChildRenderObjectElement extends RenderObjectElement {
assert
(
renderObject
==
this
.
renderObject
);
}
bool
_debugHasDuplicateIds
()
{
Set
<
Key
>
idSet
=
new
HashSet
<
Key
>();
for
(
Widget
child
in
widget
.
children
)
{
assert
(
child
!=
null
);
if
(
child
.
key
==
null
)
continue
;
// when these nodes are reordered, we just reassign the data
if
(!
idSet
.
add
(
child
.
key
))
{
throw
new
FlutterError
(
'Duplicate keys found.
\n
'
'If multiple keyed nodes exist as children of another node, they must have unique keys.
\n
'
'
$widget
has multiple children with key "
${child.key}
".'
);
}
}
return
false
;
}
@override
void
visitChildren
(
ElementVisitor
visitor
)
{
for
(
Element
child
in
_children
)
{
...
...
packages/flutter/lib/src/widgets/virtual_viewport.dart
View file @
e074af80
...
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'basic.dart'
;
import
'debug.dart'
;
import
'framework.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -169,9 +170,10 @@ abstract class VirtualViewportElement extends RenderObjectElement {
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
childIndex
=
base
+
i
;
Widget
child
=
_widgetProvider
.
getChild
(
childIndex
);
Key
key
=
new
ValueKey
<
Key
>(
child
.
key
)
??
new
ValueKey
<
int
>(
childIndex
);
Key
key
=
child
.
key
!=
null
?
new
ValueKey
<
Key
>(
child
.
key
)
:
new
ValueKey
<
int
>(
childIndex
);
newWidgets
[
i
]
=
new
RepaintBoundary
(
key:
key
,
child:
child
);
}
assert
(!
debugHasDuplicateKeys
(
widget
,
newWidgets
));
_materializedChildren
=
updateChildren
(
_materializedChildren
,
newWidgets
);
}
...
...
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