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
458d0b3d
Unverified
Commit
458d0b3d
authored
Aug 28, 2018
by
David Shuckerow
Committed by
GitHub
Aug 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the reorderable list to use the primary scroll controller when… (#20895)
parent
8b0227b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
5 deletions
+85
-5
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+7
-1
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+78
-4
No files found.
packages/flutter/lib/src/material/reorderable_list.dart
View file @
458d0b3d
...
...
@@ -173,7 +173,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
static
const
Duration
_scrollAnimationDuration
=
Duration
(
milliseconds:
200
);
// Controls scrolls and measures scroll progress.
final
ScrollController
_scrollController
=
new
ScrollController
()
;
ScrollController
_scrollController
;
// This controls the entrance of the dragging widget into a new place.
AnimationController
_entranceController
;
...
...
@@ -231,6 +231,12 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
_entranceController
.
addStatusListener
(
_onEntranceStatusChanged
);
}
@override
void
didChangeDependencies
()
{
_scrollController
=
PrimaryScrollController
.
of
(
context
)
??
new
ScrollController
();
super
.
didChangeDependencies
();
}
@override
void
dispose
()
{
_entranceController
.
dispose
();
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
458d0b3d
...
...
@@ -142,9 +142,9 @@ void main() {
));
Element
getContentElement
()
{
final
SingleChildScrollView
listScrollView
=
find
.
byType
(
SingleChildScrollView
).
evaluate
().
first
.
widget
;
final
SingleChildScrollView
listScrollView
=
tester
.
widget
(
find
.
byType
(
SingleChildScrollView
))
;
final
Widget
scrollContents
=
listScrollView
.
child
;
final
Element
contentElement
=
find
.
byElementPredicate
((
Element
element
)
=>
element
.
widget
==
scrollContents
).
evaluate
().
first
;
final
Element
contentElement
=
tester
.
element
(
find
.
byElementPredicate
((
Element
element
)
=>
element
.
widget
==
scrollContents
))
;
return
contentElement
;
}
...
...
@@ -224,6 +224,80 @@ void main() {
expect
(
findState
(
const
Key
(
'A'
)).
checked
,
true
);
});
testWidgets
(
'Uses the PrimaryScrollController when available'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
primary
=
new
ScrollController
();
final
Widget
reorderableList
=
new
ReorderableListView
(
children:
const
<
Widget
>[
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'C'
),
key:
Key
(
'C'
)),
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'B'
),
key:
Key
(
'B'
)),
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'A'
),
key:
Key
(
'A'
)),
],
onReorder:
(
int
oldIndex
,
int
newIndex
)
{},
);
Widget
buildWithScrollController
(
ScrollController
controller
)
{
return
new
MaterialApp
(
home:
new
PrimaryScrollController
(
controller:
controller
,
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
reorderableList
,
),
),
);
}
await
tester
.
pumpWidget
(
buildWithScrollController
(
primary
));
SingleChildScrollView
scrollView
=
tester
.
widget
(
find
.
byType
(
SingleChildScrollView
),
);
expect
(
scrollView
.
controller
,
primary
);
// Now try changing the primary scroll controller and checking that the scroll view gets updated.
final
ScrollController
primary2
=
new
ScrollController
();
await
tester
.
pumpWidget
(
buildWithScrollController
(
primary2
));
scrollView
=
tester
.
widget
(
find
.
byType
(
SingleChildScrollView
),
);
expect
(
scrollView
.
controller
,
primary2
);
});
testWidgets
(
'Still builds when no PrimaryScrollController is available'
,
(
WidgetTester
tester
)
async
{
final
Widget
reorderableList
=
new
ReorderableListView
(
children:
const
<
Widget
>[
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'C'
),
key:
Key
(
'C'
)),
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'B'
),
key:
Key
(
'B'
)),
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'A'
),
key:
Key
(
'A'
)),
],
onReorder:
(
int
oldIndex
,
int
newIndex
)
{},
);
final
Widget
boilerplate
=
new
Localizations
(
locale:
const
Locale
(
'en'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
new
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
reorderableList
,
),
),
);
try
{
await
tester
.
pumpWidget
(
boilerplate
);
}
catch
(
e
)
{
fail
(
'Expected no error, but got
$e
'
);
}
// Expect that we have build *a* ScrollController for use in the view.
final
SingleChildScrollView
scrollView
=
tester
.
widget
(
find
.
byType
(
SingleChildScrollView
),
);
expect
(
scrollView
.
controller
,
isNotNull
);
});
group
(
'Accessibility (a11y/Semantics)'
,
()
{
Map
<
CustomSemanticsAction
,
VoidCallback
>
getSemanticsActions
(
int
index
)
{
...
...
@@ -496,9 +570,9 @@ void main() {
));
Element
getContentElement
()
{
final
SingleChildScrollView
listScrollView
=
find
.
byType
(
SingleChildScrollView
).
evaluate
().
first
.
widget
;
final
SingleChildScrollView
listScrollView
=
tester
.
widget
(
find
.
byType
(
SingleChildScrollView
))
;
final
Widget
scrollContents
=
listScrollView
.
child
;
final
Element
contentElement
=
find
.
byElementPredicate
((
Element
element
)
=>
element
.
widget
==
scrollContents
).
evaluate
().
first
;
final
Element
contentElement
=
tester
.
element
(
find
.
byElementPredicate
((
Element
element
)
=>
element
.
widget
==
scrollContents
))
;
return
contentElement
;
}
...
...
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