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
6c04a2a1
Unverified
Commit
6c04a2a1
authored
Oct 22, 2019
by
Albertus Angga Raharja
Committed by
GitHub
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly throw error when CupertinoPageRoute builder returns null (#42602)
parent
a35c874f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
route.dart
packages/flutter/lib/src/cupertino/route.dart
+7
-6
route_test.dart
packages/flutter/test/cupertino/route_test.dart
+28
-0
No files found.
packages/flutter/lib/src/cupertino/route.dart
View file @
6c04a2a1
...
...
@@ -253,17 +253,18 @@ class CupertinoPageRoute<T> extends PageRoute<T> {
@override
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
)
{
final
Widget
child
=
builder
(
context
);
final
Widget
result
=
Semantics
(
scopesRoute:
true
,
explicitChildNodes:
true
,
child:
builder
(
context
)
,
child:
child
,
);
assert
(()
{
if
(
result
==
null
)
{
throw
FlutterError
(
'The builder for route "
${settings.name}
" returned null.
\n
'
'Route builders must never return null.'
);
if
(
child
==
null
)
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'The builder for route "
${settings.name}
" returned null.'
),
ErrorDescription
(
'Route builders must never return null.'
),
]
);
}
return
true
;
}());
...
...
packages/flutter/test/cupertino/route_test.dart
View file @
6c04a2a1
...
...
@@ -15,6 +15,34 @@ void main() {
navigatorObserver
=
MockNavigatorObserver
();
});
testWidgets
(
'Throws FlutterError with correct message when route builder returns null'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoApp
(
home:
Placeholder
(),
),
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
push
(
CupertinoPageRoute
<
void
>(
title:
'Route 1'
,
builder:
(
_
)
=>
null
,
),
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
final
dynamic
error
=
tester
.
takeException
();
expect
(
error
,
isFlutterError
);
expect
(
error
.
toStringDeep
(),
equalsIgnoringHashCodes
(
'FlutterError
\n
'
' The builder for route "null" returned null.
\n
'
' Route builders must never return null.
\n
'
));
});
testWidgets
(
'Middle auto-populates with title'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoApp
(
...
...
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