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
144434ca
Unverified
Commit
144434ca
authored
Jun 23, 2021
by
Darren Austin
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed an issue with overflow exceptions with nested lists inside a reorderable list item. (#84828)
parent
2e5284a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
1 deletion
+116
-1
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+7
-1
reorderable_list_test.dart
packages/flutter/test/widgets/reorderable_list_test.dart
+109
-0
No files found.
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
144434ca
...
...
@@ -12,6 +12,7 @@ import 'basic.dart';
import
'debug.dart'
;
import
'framework.dart'
;
import
'inherited_theme.dart'
;
import
'media_query.dart'
;
import
'overlay.dart'
;
import
'scroll_controller.dart'
;
import
'scroll_physics.dart'
;
...
...
@@ -1283,7 +1284,11 @@ class _DragItemProxy extends StatelessWidget {
final
Widget
proxyChild
=
proxyDecorator
?.
call
(
child
,
index
,
animation
.
view
)
??
child
;
final
Offset
overlayOrigin
=
_overlayOrigin
(
context
);
return
AnimatedBuilder
(
return
MediaQuery
(
// Remove the top padding so that any nested list views in the item
// won't pick up the scaffold's padding in the overlay.
data:
MediaQuery
.
of
(
context
).
removePadding
(
removeTop:
true
),
child:
AnimatedBuilder
(
animation:
animation
,
builder:
(
BuildContext
context
,
Widget
?
child
)
{
Offset
effectivePosition
=
position
;
...
...
@@ -1302,6 +1307,7 @@ class _DragItemProxy extends StatelessWidget {
);
},
child:
proxyChild
,
),
);
}
}
...
...
packages/flutter/test/widgets/reorderable_list_test.dart
View file @
144434ca
...
...
@@ -268,6 +268,115 @@ void main() {
expect
(
getItemFadeTransition
(),
findsNothing
);
});
testWidgets
(
'ReorderableList supports items with nested list views without throwing layout exception.'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
MediaQuery
(
// Ensure there is always a top padding to simulate a phone with
// safe area at the top. If the nested list doesn't have the
// padding removed before it is put into the overlay it will
// overflow the layout by the top padding.
data:
MediaQuery
.
of
(
context
).
copyWith
(
padding:
const
EdgeInsets
.
only
(
top:
50
)),
child:
child
!,
);
},
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Nested Lists'
)),
body:
ReorderableList
(
itemCount:
10
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ReorderableDragStartListener
(
index:
index
,
key:
ValueKey
<
int
>(
index
),
child:
Column
(
children:
<
Widget
>[
ListView
(
shrinkWrap:
true
,
physics:
const
ClampingScrollPhysics
(),
children:
const
<
Widget
>[
Text
(
'Other data'
),
Text
(
'Other data'
),
Text
(
'Other data'
),
],
),
],
),
);
},
onReorder:
(
int
oldIndex
,
int
newIndex
)
{},
),
),
),
);
// Start gesture on first item
final
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
const
ValueKey
<
int
>(
0
))));
await
tester
.
pump
(
kPressTimeout
);
// Drag enough for move to start
await
drag
.
moveBy
(
const
Offset
(
0
,
50
));
await
tester
.
pumpAndSettle
();
// There shouldn't be a layout overflow exception.
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'ReorderableList supports items with nested list views without throwing layout exception.'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/83224.
await
tester
.
pumpWidget
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
MediaQuery
(
// Ensure there is always a top padding to simulate a phone with
// safe area at the top. If the nested list doesn't have the
// padding removed before it is put into the overlay it will
// overflow the layout by the top padding.
data:
MediaQuery
.
of
(
context
).
copyWith
(
padding:
const
EdgeInsets
.
only
(
top:
50
)),
child:
child
!,
);
},
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Nested Lists'
)),
body:
ReorderableList
(
itemCount:
10
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ReorderableDragStartListener
(
index:
index
,
key:
ValueKey
<
int
>(
index
),
child:
Column
(
children:
<
Widget
>[
ListView
(
shrinkWrap:
true
,
physics:
const
ClampingScrollPhysics
(),
children:
const
<
Widget
>[
Text
(
'Other data'
),
Text
(
'Other data'
),
Text
(
'Other data'
),
],
),
],
),
);
},
onReorder:
(
int
oldIndex
,
int
newIndex
)
{},
),
),
),
);
// Start gesture on first item.
final
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
const
ValueKey
<
int
>(
0
))));
await
tester
.
pump
(
kPressTimeout
);
// Drag enough for move to start.
await
drag
.
moveBy
(
const
Offset
(
0
,
50
));
await
tester
.
pumpAndSettle
();
// There shouldn't be a layout overflow exception.
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'SliverReorderableList - properly animates the drop at starting position in a reversed list'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/84625
final
List
<
int
>
items
=
List
<
int
>.
generate
(
8
,
(
int
index
)
=>
index
);
...
...
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