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
021c2010
Unverified
Commit
021c2010
authored
Sep 16, 2020
by
nero
Committed by
GitHub
Sep 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ReorderableListView] remove extra margin added after picking up the item (#65080)
parent
14150788
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
16 deletions
+90
-16
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+1
-4
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+89
-12
No files found.
packages/flutter/lib/src/material/reorderable_list.dart
View file @
021c2010
...
@@ -206,9 +206,6 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
...
@@ -206,9 +206,6 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
// the currently dragging widget, such as when it first builds.
// the currently dragging widget, such as when it first builds.
static
const
double
_defaultDropAreaExtent
=
100.0
;
static
const
double
_defaultDropAreaExtent
=
100.0
;
// The additional margin to place around a computed drop area.
static
const
double
_dropAreaMargin
=
8.0
;
// How long an animation to reorder an element in the list takes.
// How long an animation to reorder an element in the list takes.
static
const
Duration
_reorderAnimationDuration
=
Duration
(
milliseconds:
200
);
static
const
Duration
_reorderAnimationDuration
=
Duration
(
milliseconds:
200
);
...
@@ -264,7 +261,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
...
@@ -264,7 +261,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
dropAreaWithoutMargin
=
_draggingFeedbackSize
.
height
;
dropAreaWithoutMargin
=
_draggingFeedbackSize
.
height
;
break
;
break
;
}
}
return
dropAreaWithoutMargin
+
_dropAreaMargin
;
return
dropAreaWithoutMargin
;
}
}
@override
@override
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
021c2010
...
@@ -177,11 +177,9 @@ void main() {
...
@@ -177,11 +177,9 @@ void main() {
return
contentElement
;
return
contentElement
;
}
}
const
double
kNonDraggingListHeight
=
292.0
;
const
double
kDraggingListHeight
=
292.0
;
// The list view pads the drop area by 8dp.
const
double
kDraggingListHeight
=
300.0
;
// Drag a normal text item
// Drag a normal text item
expect
(
getContentElement
().
size
.
height
,
k
Non
DraggingListHeight
);
expect
(
getContentElement
().
size
.
height
,
kDraggingListHeight
);
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Normal item'
)));
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Normal item'
)));
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -195,7 +193,7 @@ void main() {
...
@@ -195,7 +193,7 @@ void main() {
// Drop it
// Drop it
await
drag
.
up
();
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
getContentElement
().
size
.
height
,
k
Non
DraggingListHeight
);
expect
(
getContentElement
().
size
.
height
,
kDraggingListHeight
);
// Drag a tall item
// Drag a tall item
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Tall item'
)));
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Tall item'
)));
...
@@ -210,7 +208,48 @@ void main() {
...
@@ -210,7 +208,48 @@ void main() {
// Drop it
// Drop it
await
drag
.
up
();
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
getContentElement
().
size
.
height
,
kNonDraggingListHeight
);
expect
(
getContentElement
().
size
.
height
,
kDraggingListHeight
);
});
testWidgets
(
'Vertical drop area golden'
,
(
WidgetTester
tester
)
async
{
final
Widget
reorderableListView
=
ReorderableListView
(
children:
<
Widget
>[
Container
(
key:
const
Key
(
'pink'
),
width:
double
.
infinity
,
height:
itemHeight
,
color:
Colors
.
pink
,
),
Container
(
key:
const
Key
(
'blue'
),
width:
double
.
infinity
,
height:
itemHeight
,
color:
Colors
.
blue
,
),
Container
(
key:
const
Key
(
'green'
),
width:
double
.
infinity
,
height:
itemHeight
,
color:
Colors
.
green
,
),
],
scrollDirection:
Axis
.
vertical
,
onReorder:
(
int
oldIndex
,
int
newIndex
)
{
},
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
SizedBox
(
height:
itemHeight
*
3
,
child:
reorderableListView
,
),
));
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
const
Key
(
'blue'
))));
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pumpAndSettle
();
await
expectLater
(
find
.
byKey
(
const
Key
(
'blue'
)),
matchesGoldenFile
(
'reorderable_list_test.vertical.drop_area.png'
),
);
});
});
testWidgets
(
'Preserves children states when the list parent changes the order'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Preserves children states when the list parent changes the order'
,
(
WidgetTester
tester
)
async
{
...
@@ -721,11 +760,9 @@ void main() {
...
@@ -721,11 +760,9 @@ void main() {
return
contentElement
;
return
contentElement
;
}
}
const
double
kNonDraggingListWidth
=
292.0
;
const
double
kDraggingListWidth
=
292.0
;
// The list view pads the drop area by 8dp.
const
double
kDraggingListWidth
=
300.0
;
// Drag a normal text item
// Drag a normal text item
expect
(
getContentElement
().
size
.
width
,
k
Non
DraggingListWidth
);
expect
(
getContentElement
().
size
.
width
,
kDraggingListWidth
);
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Normal item'
)));
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Normal item'
)));
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -739,7 +776,7 @@ void main() {
...
@@ -739,7 +776,7 @@ void main() {
// Drop it
// Drop it
await
drag
.
up
();
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
getContentElement
().
size
.
width
,
k
Non
DraggingListWidth
);
expect
(
getContentElement
().
size
.
width
,
kDraggingListWidth
);
// Drag a tall item
// Drag a tall item
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Tall item'
)));
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'Tall item'
)));
...
@@ -754,9 +791,49 @@ void main() {
...
@@ -754,9 +791,49 @@ void main() {
// Drop it
// Drop it
await
drag
.
up
();
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
getContentElement
().
size
.
width
,
k
Non
DraggingListWidth
);
expect
(
getContentElement
().
size
.
width
,
kDraggingListWidth
);
});
});
testWidgets
(
'Horizontal drop area golden'
,
(
WidgetTester
tester
)
async
{
final
Widget
reorderableListView
=
ReorderableListView
(
children:
<
Widget
>[
Container
(
key:
const
Key
(
'pink'
),
height:
double
.
infinity
,
width:
itemHeight
,
color:
Colors
.
pink
,
),
Container
(
key:
const
Key
(
'blue'
),
height:
double
.
infinity
,
width:
itemHeight
,
color:
Colors
.
blue
,
),
Container
(
key:
const
Key
(
'green'
),
height:
double
.
infinity
,
width:
itemHeight
,
color:
Colors
.
green
,
),
],
scrollDirection:
Axis
.
horizontal
,
onReorder:
(
int
oldIndex
,
int
newIndex
)
{
},
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
SizedBox
(
width:
itemHeight
*
3
,
child:
reorderableListView
,
),
));
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
const
Key
(
'blue'
))));
await
tester
.
pump
(
kLongPressTimeout
+
kPressTimeout
);
await
tester
.
pumpAndSettle
();
await
expectLater
(
find
.
byKey
(
const
Key
(
'blue'
)),
matchesGoldenFile
(
'reorderable_list_test.horizontal.drop_area.png'
),
);
});
testWidgets
(
'Preserves children states when the list parent changes the order'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Preserves children states when the list parent changes the order'
,
(
WidgetTester
tester
)
async
{
_StatefulState
findState
(
Key
key
)
{
_StatefulState
findState
(
Key
key
)
{
...
...
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