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
14440b14
Commit
14440b14
authored
Mar 23, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2846 from HansMuller/two_level_list
TwoLevelList fails to restore sublist expanded state
parents
a8c108de
67a18fa5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
18 deletions
+61
-18
two_level_list.dart
packages/flutter/lib/src/material/two_level_list.dart
+5
-2
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+22
-0
debug.dart
packages/flutter/lib/src/widgets/debug.dart
+30
-13
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+1
-1
virtual_viewport.dart
packages/flutter/lib/src/widgets/virtual_viewport.dart
+3
-2
No files found.
packages/flutter/lib/src/material/two_level_list.dart
View file @
14440b14
...
@@ -154,11 +154,14 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
...
@@ -154,11 +154,14 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> {
}
}
class
TwoLevelList
extends
StatelessWidget
{
class
TwoLevelList
extends
StatelessWidget
{
TwoLevelList
({
Key
key
,
this
.
items
,
this
.
type
:
MaterialListType
.
twoLine
})
:
super
(
key:
key
);
TwoLevelList
({
Key
key
,
this
.
scrollableKey
,
this
.
items
,
this
.
type
:
MaterialListType
.
twoLine
})
:
super
(
key:
key
);
final
List
<
Widget
>
items
;
final
List
<
Widget
>
items
;
final
MaterialListType
type
;
final
MaterialListType
type
;
final
Key
scrollableKey
;
@override
@override
Widget
build
(
BuildContext
context
)
=>
new
Block
(
children:
items
);
Widget
build
(
BuildContext
context
)
{
return
new
Block
(
children:
KeyedSubtree
.
ensureUniqueKeysForList
(
items
),
scrollableKey:
scrollableKey
);
}
}
}
packages/flutter/lib/src/widgets/basic.dart
View file @
14440b14
...
@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Image;
...
@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Image;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'debug.dart'
;
import
'framework.dart'
;
import
'framework.dart'
;
export
'package:flutter/animation.dart'
;
export
'package:flutter/animation.dart'
;
...
@@ -2575,6 +2576,27 @@ class KeyedSubtree extends StatelessWidget {
...
@@ -2575,6 +2576,27 @@ class KeyedSubtree extends StatelessWidget {
/// The widget below this widget in the tree.
/// The widget below this widget in the tree.
final
Widget
child
;
final
Widget
child
;
/// Wrap each item in a KeyedSubtree whose key is based on the item's existing key or
/// its list index + baseIndex.
static
List
<
Widget
>
ensureUniqueKeysForList
(
Iterable
<
Widget
>
items
,
{
int
baseIndex:
0
})
{
if
(
items
==
null
||
items
.
isEmpty
)
return
items
;
List
<
Widget
>
itemsWithUniqueKeys
=
<
Widget
>[];
int
itemIndex
=
baseIndex
;
for
(
Widget
item
in
items
)
{
itemsWithUniqueKeys
.
add
(
new
KeyedSubtree
(
key:
item
.
key
!=
null
?
new
ValueKey
<
Key
>(
item
.
key
)
:
new
ValueKey
<
int
>(
itemIndex
),
child:
item
));
itemIndex
+=
1
;
}
assert
(!
debugItemsHaveDuplicateKeys
(
itemsWithUniqueKeys
));
return
items
;
}
@override
@override
Widget
build
(
BuildContext
context
)
=>
child
;
Widget
build
(
BuildContext
context
)
=>
child
;
}
}
...
...
packages/flutter/lib/src/widgets/debug.dart
View file @
14440b14
...
@@ -25,21 +25,38 @@ bool debugCheckHasMediaQuery(BuildContext context) {
...
@@ -25,21 +25,38 @@ bool debugCheckHasMediaQuery(BuildContext context) {
return
true
;
return
true
;
}
}
bool
debugHasDuplicateKeys
(
Widget
parent
,
Iterable
<
Widget
>
children
)
{
Key
_firstNonUniqueKey
(
Iterable
<
Widget
>
widgets
)
{
assert
(()
{
Set
<
Key
>
keySet
=
new
HashSet
<
Key
>();
Set
<
Key
>
keySet
=
new
HashSet
<
Key
>();
for
(
Widget
child
in
children
)
{
for
(
Widget
widget
in
widgets
)
{
assert
(
child
!=
null
);
assert
(
widget
!=
null
);
if
(
child
.
key
==
null
)
if
(
widget
.
key
==
null
)
continue
;
continue
;
if
(!
keySet
.
add
(
child
.
key
))
{
if
(!
keySet
.
add
(
widget
.
key
))
return
widget
.
key
;
}
return
null
;
}
bool
debugChildrenHaveDuplicateKeys
(
Widget
parent
,
Iterable
<
Widget
>
children
)
{
assert
(()
{
final
Key
nonUniqueKey
=
_firstNonUniqueKey
(
children
);
if
(
nonUniqueKey
!=
null
)
{
throw
new
FlutterError
(
throw
new
FlutterError
(
'Duplicate keys found.
\n
'
'Duplicate keys found.
\n
'
'If multiple keyed nodes exist as children of another node, they must have unique keys.
\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}
"
.'
'
$parent
has multiple children with key
$nonUniqueKey
.'
);
);
}
}
}
return
true
;
});
return
false
;
}
bool
debugItemsHaveDuplicateKeys
(
Iterable
<
Widget
>
items
)
{
assert
(()
{
final
Key
nonUniqueKey
=
_firstNonUniqueKey
(
items
);
if
(
nonUniqueKey
!=
null
)
throw
new
FlutterError
(
'Duplicate key found:
$nonUniqueKey
.
\n
'
);
return
true
;
return
true
;
});
});
return
false
;
return
false
;
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
14440b14
...
@@ -1937,7 +1937,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement {
...
@@ -1937,7 +1937,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement {
/// Instantiation of RenderObjectWidgets that can have a list of children
/// Instantiation of RenderObjectWidgets that can have a list of children
class
MultiChildRenderObjectElement
extends
RenderObjectElement
{
class
MultiChildRenderObjectElement
extends
RenderObjectElement
{
MultiChildRenderObjectElement
(
MultiChildRenderObjectWidget
widget
)
:
super
(
widget
)
{
MultiChildRenderObjectElement
(
MultiChildRenderObjectWidget
widget
)
:
super
(
widget
)
{
assert
(!
debug
Has
DuplicateKeys
(
widget
,
widget
.
children
));
assert
(!
debug
ChildrenHave
DuplicateKeys
(
widget
,
widget
.
children
));
}
}
@override
@override
...
...
packages/flutter/lib/src/widgets/virtual_viewport.dart
View file @
14440b14
...
@@ -173,8 +173,9 @@ abstract class VirtualViewportElement extends RenderObjectElement {
...
@@ -173,8 +173,9 @@ abstract class VirtualViewportElement extends RenderObjectElement {
Key
key
=
child
.
key
!=
null
?
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
);
newWidgets
[
i
]
=
new
RepaintBoundary
(
key:
key
,
child:
child
);
}
}
assert
(!
debugHasDuplicateKeys
(
widget
,
newWidgets
));
_materializedChildren
=
updateChildren
(
_materializedChildren
,
newWidgets
);
assert
(!
debugChildrenHaveDuplicateKeys
(
widget
,
newWidgets
));
_materializedChildren
=
updateChildren
(
_materializedChildren
,
newWidgets
.
toList
());
}
}
@override
@override
...
...
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