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
01afd64b
Unverified
Commit
01afd64b
authored
Oct 13, 2021
by
The one with the braid (she/her) | Dфҿ mit dem Zopf (sie/ihr)
Committed by
GitHub
Oct 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented getter to expose current url strategy for web plugins (#90708)
parent
e3220123
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
AUTHORS
AUTHORS
+1
-0
url_strategy_integration.dart
...s/web_e2e_tests/test_driver/url_strategy_integration.dart
+6
-1
js_url_strategy.dart
...utter_web_plugins/lib/src/navigation/js_url_strategy.dart
+2
-3
url_strategy.dart
.../flutter_web_plugins/lib/src/navigation/url_strategy.dart
+21
-0
No files found.
AUTHORS
View file @
01afd64b
...
...
@@ -88,3 +88,4 @@ Casey Rogers <caseycrogers@berkeley.edu>
Pradumna Saraf <pradumnasaraf@gmail.com>
Kai Yu <yk3372@gmail.com>
Denis Grafov <grafov.denis@gmail.com>
TheOneWithTheBraid <the-one@with-the-braid.cf>
dev/integration_tests/web_e2e_tests/test_driver/url_strategy_integration.dart
View file @
01afd64b
...
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:html'
as
html
;
import
'dart:ui'
as
ui
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
...
...
@@ -27,6 +28,9 @@ void main() {
app
.
main
();
await
tester
.
pumpAndSettle
();
// checking whether the previously set strategy is properly preserved
expect
(
urlStrategy
,
strategy
);
expect
(
strategy
.
getPath
(),
'/'
);
final
NavigatorState
navigator
=
app
.
navKey
.
currentState
!;
...
...
@@ -44,7 +48,8 @@ void main() {
class
TestUrlStrategy
extends
UrlStrategy
{
/// Creates a instance of [TestUrlStrategy] with an empty string as the
/// path.
factory
TestUrlStrategy
()
=>
TestUrlStrategy
.
fromEntry
(
const
TestHistoryEntry
(
null
,
null
,
''
));
factory
TestUrlStrategy
()
=>
TestUrlStrategy
.
fromEntry
(
const
TestHistoryEntry
(
null
,
null
,
''
));
/// Creates an instance of [TestUrlStrategy] and populates it with a list
/// that has [initialEntry] as the only item.
...
...
packages/flutter_web_plugins/lib/src/navigation/js_url_strategy.dart
View file @
01afd64b
...
...
@@ -23,7 +23,7 @@ typedef _JsSetUrlStrategy = void Function(JsUrlStrategy?);
/// A JavaScript hook to customize the URL strategy of a Flutter app.
//
// Keep this in sync with the JS name in the web engine. Find it at:
// https://github.com/flutter/engine/blob/
custom_location_strategy
/lib/web_ui/lib/src/engine/navigation/js_url_strategy.dart
// https://github.com/flutter/engine/blob/
master
/lib/web_ui/lib/src/engine/navigation/js_url_strategy.dart
//
// TODO(mdebbar): Add integration test https://github.com/flutter/flutter/issues/66852
@JS
(
'_flutter_web_set_location_strategy'
)
...
...
@@ -37,8 +37,7 @@ typedef _AddPopStateListener = ui.VoidCallback Function(html.EventListener);
typedef
_StringToString
=
String
Function
(
String
);
typedef
_StateOperation
=
void
Function
(
Object
state
,
String
title
,
String
url
);
typedef
_StateOperation
=
void
Function
(
Object
state
,
String
title
,
String
url
);
typedef
_HistoryMove
=
Future
<
void
>
Function
(
int
count
);
...
...
packages/flutter_web_plugins/lib/src/navigation/url_strategy.dart
View file @
01afd64b
...
...
@@ -9,10 +9,30 @@ import 'dart:ui' as ui;
import
'js_url_strategy.dart'
;
import
'utils.dart'
;
/// Saves the current [UrlStrategy] to be accessed by [urlStrategy] or
/// [setUrlStrategy].
///
/// This is particularly required for web plugins relying on valid URL
/// encoding.
//
// Keep this in sync with the default url strategy in the web engine.
// Find it at:
// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/window.dart#L360
//
UrlStrategy
?
_urlStrategy
=
const
HashUrlStrategy
();
/// Returns the present [UrlStrategy] for handling the browser URL.
///
/// In case null is returned, the browser integration has been manually
/// disabled by [setUrlStrategy].
UrlStrategy
?
get
urlStrategy
=>
_urlStrategy
;
/// Change the strategy to use for handling browser URL.
///
/// Setting this to null disables all integration with the browser history.
void
setUrlStrategy
(
UrlStrategy
?
strategy
)
{
_urlStrategy
=
strategy
;
JsUrlStrategy
?
jsUrlStrategy
;
if
(
strategy
!=
null
)
{
jsUrlStrategy
=
convertToJsUrlStrategy
(
strategy
);
...
...
@@ -285,6 +305,7 @@ class BrowserPlatformLocation extends PlatformLocation {
static
const
String
_defaultSearch
=
''
;
html
.
Location
get
_location
=>
html
.
window
.
location
;
html
.
History
get
_history
=>
html
.
window
.
history
;
@override
...
...
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