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
1946fc4d
Unverified
Commit
1946fc4d
authored
Oct 07, 2019
by
Mouad Debbar
Committed by
GitHub
Oct 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Always send the route name even if it's null (#41996)
parent
9638756c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
9 deletions
+54
-9
route_notification_messages.dart
.../flutter/lib/src/widgets/route_notification_messages.dart
+7
-9
route_notification_messages_test.dart
...lutter/test/widgets/route_notification_messages_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/route_notification_messages.dart
View file @
1946fc4d
...
...
@@ -29,14 +29,12 @@ class RouteNotificationMessages {
static
void
_notifyRouteChange
(
String
methodName
,
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
final
String
previousRouteName
=
previousRoute
?.
settings
?.
name
;
final
String
routeName
=
route
?.
settings
?.
name
;
if
(
previousRouteName
!=
null
||
routeName
!=
null
)
{
SystemChannels
.
navigation
.
invokeMethod
<
void
>(
methodName
,
<
String
,
dynamic
>{
'previousRouteName'
:
previousRouteName
,
'routeName'
:
routeName
,
},
);
}
SystemChannels
.
navigation
.
invokeMethod
<
void
>(
methodName
,
<
String
,
dynamic
>{
'previousRouteName'
:
previousRouteName
,
'routeName'
:
routeName
,
},
);
}
}
packages/flutter/test/widgets/route_notification_messages_test.dart
View file @
1946fc4d
...
...
@@ -167,4 +167,51 @@ void main() {
},
));
});
testWidgets
(
'Nameless routes should send platform messages'
,
(
WidgetTester
tester
)
async
{
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
SystemChannels
.
navigation
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
log
.
add
(
methodCall
);
});
await
tester
.
pumpWidget
(
MaterialApp
(
initialRoute:
'/home'
,
routes:
<
String
,
WidgetBuilder
>{
'/home'
:
(
BuildContext
context
)
{
return
OnTapPage
(
id:
'Home'
,
onTap:
()
{
// Create a route with no name.
final
Route
<
void
>
route
=
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
=>
const
Text
(
'Nameless Route'
),
);
Navigator
.
push
<
void
>(
context
,
route
);
},
);
},
},
));
expect
(
log
,
hasLength
(
1
));
expect
(
log
.
last
,
isMethodCall
(
'routePushed'
,
arguments:
<
String
,
dynamic
>{
'previousRouteName'
:
null
,
'routeName'
:
'/home'
,
}),
);
await
tester
.
tap
(
find
.
text
(
'Home'
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
log
,
hasLength
(
2
));
expect
(
log
.
last
,
isMethodCall
(
'routePushed'
,
arguments:
<
String
,
dynamic
>{
'previousRouteName'
:
'/home'
,
'routeName'
:
null
,
}),
);
});
}
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