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
43001a3a
Commit
43001a3a
authored
Oct 15, 2018
by
Mouad Debbar
Committed by
Michael Goderbauer
Oct 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly throw when MaterialPageRoute's builder returns null (#22885)
parent
8e2ca93f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
page.dart
packages/flutter/lib/src/material/page.dart
+8
-7
page_test.dart
packages/flutter/test/material/page_test.dart
+18
-0
No files found.
packages/flutter/lib/src/material/page.dart
View file @
43001a3a
...
...
@@ -82,12 +82,9 @@ class MaterialPageRoute<T> extends PageRoute<T> {
}
@override
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
)
{
final
Widget
result
=
Semantics
(
scopesRoute:
true
,
explicitChildNodes:
true
,
child:
builder
(
context
),
);
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
)
{
final
Widget
result
=
builder
(
context
);
assert
(()
{
if
(
result
==
null
)
{
throw
FlutterError
(
...
...
@@ -97,7 +94,11 @@ class MaterialPageRoute<T> extends PageRoute<T> {
}
return
true
;
}());
return
result
;
return
Semantics
(
scopesRoute:
true
,
explicitChildNodes:
true
,
child:
result
,
);
}
@override
...
...
packages/flutter/test/material/page_test.dart
View file @
43001a3a
...
...
@@ -452,4 +452,22 @@ void main() {
// Page 1 is back where it started.
expect
(
widget1InitialTopLeft
==
widget1TransientTopLeft
,
true
);
});
testWidgets
(
'throws when builder returns null'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'Home'
),
));
// No exceptions yet.
expect
(
tester
.
takeException
(),
isNull
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
))
.
push
(
MaterialPageRoute
<
void
>(
settings:
const
RouteSettings
(
name:
'broken'
),
builder:
(
BuildContext
context
)
=>
null
,
));
await
tester
.
pumpAndSettle
();
// An exception should've been thrown because the `builder` returned null.
expect
(
tester
.
takeException
(),
isInstanceOf
<
FlutterError
>());
});
}
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