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
cb0bdb49
Unverified
Commit
cb0bdb49
authored
Oct 08, 2020
by
chunhtai
Committed by
GitHub
Oct 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make router assert more strict (#67672)
parent
973404a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletion
+50
-1
router.dart
packages/flutter/lib/src/widgets/router.dart
+6
-1
router_test.dart
packages/flutter/test/widgets/router_test.dart
+44
-0
No files found.
packages/flutter/lib/src/widgets/router.dart
View file @
cb0bdb49
...
@@ -245,7 +245,12 @@ class Router<T> extends StatefulWidget {
...
@@ -245,7 +245,12 @@ class Router<T> extends StatefulWidget {
this
.
routeInformationParser
,
this
.
routeInformationParser
,
required
this
.
routerDelegate
,
required
this
.
routerDelegate
,
this
.
backButtonDispatcher
,
this
.
backButtonDispatcher
,
})
:
assert
(
routeInformationProvider
==
null
||
routeInformationParser
!=
null
),
})
:
assert
(
(
routeInformationProvider
==
null
)
==
(
routeInformationParser
==
null
),
'You must provide both routeInformationProvider and routeInformationParser '
'if this router parses route information. Otheriwse, they should both '
'be null.'
),
assert
(
routerDelegate
!=
null
),
assert
(
routerDelegate
!=
null
),
super
(
key:
key
);
super
(
key:
key
);
...
...
packages/flutter/test/widgets/router_test.dart
View file @
cb0bdb49
...
@@ -118,6 +118,50 @@ void main() {
...
@@ -118,6 +118,50 @@ void main() {
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
});
testWidgets
(
'Router throw when passes only routeInformationProvider'
,
(
WidgetTester
tester
)
async
{
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
();
provider
.
value
=
const
RouteInformation
(
location:
'initial'
,
);
try
{
Router
<
RouteInformation
>(
routeInformationProvider:
provider
,
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
},
),
);
}
on
AssertionError
catch
(
e
)
{
expect
(
e
.
message
,
'You must provide both routeInformationProvider and '
'routeInformationParser if this router parses route information. '
'Otheriwse, they should both be null.'
);
}
});
testWidgets
(
'Router throw when passes only routeInformationParser'
,
(
WidgetTester
tester
)
async
{
try
{
Router
<
RouteInformation
>(
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
},
),
);
}
on
AssertionError
catch
(
e
)
{
expect
(
e
.
message
,
'You must provide both routeInformationProvider and '
'routeInformationParser if this router parses route information. '
'Otheriwse, they should both be null.'
);
}
});
testWidgets
(
'PopNavigatorRouterDelegateMixin works'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'PopNavigatorRouterDelegateMixin works'
,
(
WidgetTester
tester
)
async
{
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
();
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
();
provider
.
value
=
const
RouteInformation
(
provider
.
value
=
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