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
43e3328e
Unverified
Commit
43e3328e
authored
Mar 16, 2021
by
Abhishek Ghaskata
Committed by
GitHub
Mar 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add assertion of recordable list (#76272)
parent
5ab34744
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+8
-0
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+16
-0
No files found.
packages/flutter/lib/src/material/reorderable_list.dart
View file @
43e3328e
...
...
@@ -457,6 +457,14 @@ class _ReorderableListContentState extends State<_ReorderableListContent> {
Widget
_itemBuilder
(
BuildContext
context
,
int
index
)
{
final
Widget
item
=
widget
.
itemBuilder
(
context
,
index
);
assert
(()
{
if
(
item
.
key
==
null
)
{
throw
FlutterError
(
'Every item of ReorderableListView must have a key.'
);
}
return
true
;
}());
// TODO(goderbauer): The semantics stuff should probably happen inside
// _ReorderableItem so the widget versions can have them as well.
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
43e3328e
...
...
@@ -1326,6 +1326,22 @@ void main() {
}
expect
(
items
.
take
(
8
),
orderedEquals
(<
int
>[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
]));
});
testWidgets
(
'ReorderableListView throws an error when key is not passed to its children'
,
(
WidgetTester
tester
)
async
{
final
Widget
reorderableListView
=
ReorderableListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
child:
Text
(
'Item
$index
'
));
},
itemCount:
3
,
onReorder:
(
int
oldIndex
,
int
newIndex
)
{
},
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
reorderableListView
,
));
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
toString
(),
contains
(
'Every item of ReorderableListView must have a key.'
));
});
}
Future
<
void
>
longPressDrag
(
WidgetTester
tester
,
Offset
start
,
Offset
end
)
async
{
...
...
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