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
fbc15384
Unverified
Commit
fbc15384
authored
Aug 27, 2020
by
chunhtai
Committed by
GitHub
Aug 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes router to not report route information when it is already up to… (#64596)
parent
8a6a76a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
router.dart
packages/flutter/lib/src/widgets/router.dart
+2
-1
router_test.dart
packages/flutter/test/widgets/router_test.dart
+39
-0
No files found.
packages/flutter/lib/src/widgets/router.dart
View file @
fbc15384
...
...
@@ -395,7 +395,6 @@ class _RouterState<T> extends State<Router<T>> {
if
(
widget
.
routeInformationProvider
!=
null
)
{
_processInitialRoute
();
}
_lastSeenLocation
=
widget
.
routeInformationProvider
?.
value
?.
location
;
}
bool
_routeInformationReportingTaskScheduled
=
false
;
...
...
@@ -552,6 +551,7 @@ class _RouterState<T> extends State<Router<T>> {
void
_processInitialRoute
()
{
_currentRouteInformationParserTransaction
=
Object
();
_currentRouterDelegateTransaction
=
Object
();
_lastSeenLocation
=
widget
.
routeInformationProvider
.
value
.
location
;
widget
.
routeInformationParser
.
parseRouteInformation
(
widget
.
routeInformationProvider
.
value
)
.
then
<
T
>(
_verifyRouteInformationParserStillCurrent
(
_currentRouteInformationParserTransaction
,
widget
))
...
...
@@ -563,6 +563,7 @@ class _RouterState<T> extends State<Router<T>> {
void
_handleRouteInformationProviderNotification
()
{
_currentRouteInformationParserTransaction
=
Object
();
_currentRouterDelegateTransaction
=
Object
();
_lastSeenLocation
=
widget
.
routeInformationProvider
.
value
.
location
;
widget
.
routeInformationParser
.
parseRouteInformation
(
widget
.
routeInformationProvider
.
value
)
.
then
<
T
>(
_verifyRouteInformationParserStillCurrent
(
_currentRouteInformationParserTransaction
,
widget
))
...
...
packages/flutter/test/widgets/router_test.dart
View file @
fbc15384
...
...
@@ -434,6 +434,45 @@ void main() {
expect
(
reportedRouteInformation
.
location
,
'update'
);
});
testWidgets
(
'router does not report when route information is up to date with route information provider'
,
(
WidgetTester
tester
)
async
{
RouteInformation
reportedRouteInformation
;
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
onRouterReport:
(
RouteInformation
information
)
{
reportedRouteInformation
=
information
;
}
);
provider
.
value
=
const
RouteInformation
(
location:
'initial'
,
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
);
delegate
.
builder
=
(
BuildContext
context
,
RouteInformation
routeInformation
)
{
return
Text
(
routeInformation
.
location
);
};
await
tester
.
pumpWidget
(
buildBoilerPlate
(
Router
<
RouteInformation
>(
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
delegate
,
)
));
expect
(
find
.
text
(
'initial'
),
findsOneWidget
);
expect
(
reportedRouteInformation
,
isNull
);
// This will cause the router to rebuild.
provider
.
value
=
const
RouteInformation
(
location:
'update'
,
);
// This will schedule the route reporting.
delegate
.
notifyListeners
();
await
tester
.
pump
();
expect
(
find
.
text
(
'initial'
),
findsNothing
);
expect
(
find
.
text
(
'update'
),
findsOneWidget
);
// The router should not report because the route name is already up to
// date.
expect
(
reportedRouteInformation
,
isNull
);
});
testWidgets
(
'PlatformRouteInformationProvider works'
,
(
WidgetTester
tester
)
async
{
final
RouteInformationProvider
provider
=
PlatformRouteInformationProvider
(
initialRouteInformation:
const
RouteInformation
(
...
...
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