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
458f6f45
Unverified
Commit
458f6f45
authored
Apr 07, 2021
by
Mouad Debbar
Committed by
GitHub
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Fix url strategy null safety (#79888)
parent
eb9a2f0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
js_url_strategy.dart
...utter_web_plugins/lib/src/navigation/js_url_strategy.dart
+2
-2
url_strategy.dart
.../flutter_web_plugins/lib/src/navigation/url_strategy.dart
+8
-8
url_strategy_test.dart
...lutter_web_plugins/test/navigation/url_strategy_test.dart
+15
-6
No files found.
packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart
View file @
458f6f45
...
...
@@ -90,12 +90,12 @@ abstract class JsUrlStrategy {
/// Push a new history entry.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
external
void
pushState
(
Object
state
,
String
title
,
String
url
);
external
void
pushState
(
Object
?
state
,
String
title
,
String
url
);
/// Replace the currently active history entry.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
external
void
replaceState
(
Object
state
,
String
title
,
String
url
);
external
void
replaceState
(
Object
?
state
,
String
title
,
String
url
);
/// Moves forwards or backwards through the history stack.
///
...
...
packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart
View file @
458f6f45
...
...
@@ -48,12 +48,12 @@ abstract class UrlStrategy {
/// Push a new history entry.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
void
pushState
(
Object
state
,
String
title
,
String
url
);
void
pushState
(
Object
?
state
,
String
title
,
String
url
);
/// Replace the currently active history entry.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
void
replaceState
(
Object
state
,
String
title
,
String
url
);
void
replaceState
(
Object
?
state
,
String
title
,
String
url
);
/// Moves forwards or backwards through the history stack.
///
...
...
@@ -129,12 +129,12 @@ class HashUrlStrategy extends UrlStrategy {
}
@override
void
pushState
(
Object
state
,
String
title
,
String
url
)
{
void
pushState
(
Object
?
state
,
String
title
,
String
url
)
{
_platformLocation
.
pushState
(
state
,
title
,
prepareExternalUrl
(
url
));
}
@override
void
replaceState
(
Object
state
,
String
title
,
String
url
)
{
void
replaceState
(
Object
?
state
,
String
title
,
String
url
)
{
_platformLocation
.
replaceState
(
state
,
title
,
prepareExternalUrl
(
url
));
}
...
...
@@ -245,12 +245,12 @@ abstract class PlatformLocation {
/// Adds a new entry to the browser history stack.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
void
pushState
(
Object
state
,
String
title
,
String
url
);
void
pushState
(
Object
?
state
,
String
title
,
String
url
);
/// Replaces the current entry in the browser history stack.
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
void
replaceState
(
Object
state
,
String
title
,
String
url
);
void
replaceState
(
Object
?
state
,
String
title
,
String
url
);
/// Moves forwards or backwards through the history stack.
///
...
...
@@ -310,12 +310,12 @@ class BrowserPlatformLocation extends PlatformLocation {
Object
?
get
state
=>
_history
.
state
;
@override
void
pushState
(
Object
state
,
String
title
,
String
url
)
{
void
pushState
(
Object
?
state
,
String
title
,
String
url
)
{
_history
.
pushState
(
state
,
title
,
url
);
}
@override
void
replaceState
(
Object
state
,
String
title
,
String
url
)
{
void
replaceState
(
Object
?
state
,
String
title
,
String
url
)
{
_history
.
replaceState
(
state
,
title
,
url
);
}
...
...
packages/flutter_web_plugins/test/navigation/url_strategy_test.dart
View file @
458f6f45
...
...
@@ -17,6 +17,12 @@ void main() {
location
=
TestPlatformLocation
();
});
test
(
'allows null state'
,
()
{
final
HashUrlStrategy
strategy
=
HashUrlStrategy
(
location
);
expect
(()
=>
strategy
.
pushState
(
null
,
''
,
'/'
),
returnsNormally
);
expect
(()
=>
strategy
.
replaceState
(
null
,
''
,
'/'
),
returnsNormally
);
});
test
(
'leading slash is optional'
,
()
{
final
HashUrlStrategy
strategy
=
HashUrlStrategy
(
location
);
...
...
@@ -48,6 +54,13 @@ void main() {
location
=
TestPlatformLocation
();
});
test
(
'allows null state'
,
()
{
location
.
baseHref
=
'/'
;
final
PathUrlStrategy
strategy
=
PathUrlStrategy
(
location
);
expect
(()
=>
strategy
.
pushState
(
null
,
''
,
'/'
),
returnsNormally
);
expect
(()
=>
strategy
.
replaceState
(
null
,
''
,
'/'
),
returnsNormally
);
});
test
(
'validates base href'
,
()
{
location
.
baseHref
=
'/'
;
expect
(
...
...
@@ -159,14 +172,10 @@ class TestPlatformLocation extends PlatformLocation {
}
@override
void
pushState
(
dynamic
state
,
String
title
,
String
url
)
{
throw
UnimplementedError
();
}
void
pushState
(
Object
?
state
,
String
title
,
String
url
)
{}
@override
void
replaceState
(
dynamic
state
,
String
title
,
String
url
)
{
throw
UnimplementedError
();
}
void
replaceState
(
Object
?
state
,
String
title
,
String
url
)
{}
@override
void
go
(
int
count
)
{
...
...
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