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
9357e70d
Unverified
Commit
9357e70d
authored
Jul 30, 2019
by
LongCatIsLooong
Committed by
GitHub
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use FlutterError in MultiChildRenderObjectWidget (#37187)
parent
a0b69f30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+3
-2
multichild_test.dart
packages/flutter/test/widgets/multichild_test.dart
+20
-0
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
9357e70d
...
...
@@ -1688,8 +1688,9 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
assert
(()
{
final
int
index
=
children
.
indexOf
(
null
);
if
(
index
>=
0
)
{
throw
AssertionError
(
"The widget's children must not contain any null values, but a null value was found at index
$index
"
throw
FlutterError
(
"
$runtimeType
's children must not contain any null values, "
'but a null value was found at index
$index
'
);
}
return
true
;
...
...
packages/flutter/test/widgets/multichild_test.dart
View file @
9357e70d
...
...
@@ -31,6 +31,13 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
}
}
class
MockMultiChildRenderObjectWidget
extends
MultiChildRenderObjectWidget
{
MockMultiChildRenderObjectWidget
({
Key
key
,
List
<
Widget
>
children
})
:
super
(
key:
key
,
children:
children
);
@override
RenderObject
createRenderObject
(
BuildContext
context
)
=>
null
;
}
void
main
(
)
{
testWidgets
(
'MultiChildRenderObjectElement control test'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -345,4 +352,17 @@ void main() {
checkTree
(
tester
,
<
BoxDecoration
>[
kBoxDecorationB
,
kBoxDecorationC
]);
});
// Regression test for https://github.com/flutter/flutter/issues/37136.
test
(
'provides useful assertion message when one of the children is null'
,
()
{
bool
assertionTriggered
=
false
;
try
{
MockMultiChildRenderObjectWidget
(
children:
const
<
Widget
>[
null
]);
}
catch
(
e
)
{
expect
(
e
.
toString
(),
contains
(
"MockMultiChildRenderObjectWidget's children must not contain any null values,"
));
assertionTriggered
=
true
;
}
expect
(
assertionTriggered
,
isTrue
);
});
}
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