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
3138cce7
Unverified
Commit
3138cce7
authored
Jan 18, 2022
by
wangying
Committed by
GitHub
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support configure a custom launch url for flutter web (#95002)
parent
2c393757
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
1 deletion
+46
-1
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+1
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+5
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+4
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+12
-1
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+24
-0
No files found.
packages/flutter_tools/lib/src/commands/run.dart
View file @
3138cce7
...
...
@@ -228,6 +228,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
webRunHeadless:
featureFlags
.
isWebEnabled
&&
boolArg
(
'web-run-headless'
),
webBrowserDebugPort:
browserDebugPort
,
webEnableExpressionEvaluation:
featureFlags
.
isWebEnabled
&&
boolArg
(
'web-enable-expression-evaluation'
),
webLaunchUrl:
featureFlags
.
isWebEnabled
?
stringArg
(
'web-launch-url'
)
:
null
,
vmserviceOutFile:
stringArg
(
'vmservice-out-file'
),
fastStart:
argParser
.
options
.
containsKey
(
'fast-start'
)
&&
boolArg
(
'fast-start'
)
...
...
packages/flutter_tools/lib/src/device.dart
View file @
3138cce7
...
...
@@ -763,6 +763,7 @@ class DebuggingOptions {
this
.
webRunHeadless
=
false
,
this
.
webBrowserDebugPort
,
this
.
webEnableExpressionEvaluation
=
false
,
this
.
webLaunchUrl
,
this
.
vmserviceOutFile
,
this
.
fastStart
=
false
,
this
.
nullAssertions
=
false
,
...
...
@@ -779,6 +780,7 @@ class DebuggingOptions {
this
.
webUseSseForInjectedClient
=
true
,
this
.
webRunHeadless
=
false
,
this
.
webBrowserDebugPort
,
this
.
webLaunchUrl
,
this
.
cacheSkSL
=
false
,
this
.
traceAllowlist
,
})
:
debuggingEnabled
=
false
,
...
...
@@ -852,6 +854,9 @@ class DebuggingOptions {
/// Enable expression evaluation for web target.
final
bool
webEnableExpressionEvaluation
;
/// Allow developers to customize the browser's launch URL
final
String
?
webLaunchUrl
;
/// A file where the VM Service URL should be written after the application is started.
final
String
?
vmserviceOutFile
;
final
bool
fastStart
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
3138cce7
...
...
@@ -263,6 +263,10 @@ abstract class FlutterCommand extends Command<void> {
help:
'Enables expression evaluation in the debugger.'
,
hide:
!
verboseHelp
,
);
argParser
.
addOption
(
'web-launch-url'
,
help:
'The URL to provide to the browser. Defaults to an HTTP URL with the host '
'name of "--web-hostname", the port of "--web-port", and the path set to "/".'
,
);
}
void
usesTargetOption
()
{
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
3138cce7
...
...
@@ -6,6 +6,7 @@ import 'package:meta/meta.dart';
import
'package:process/process.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -128,7 +129,17 @@ abstract class ChromiumDevice extends Device {
})
async
{
// See [ResidentWebRunner.run] in flutter_tools/lib/src/resident_web_runner.dart
// for the web initialization and server logic.
final
String
url
=
platformArgs
[
'uri'
]!
as
String
;
String
url
;
if
(
debuggingOptions
.
webLaunchUrl
!=
null
)
{
final
RegExp
pattern
=
RegExp
(
r'^((http)?:\/\/)[^\s]+'
);
if
(
pattern
.
hasMatch
(
debuggingOptions
.
webLaunchUrl
!))
{
url
=
debuggingOptions
.
webLaunchUrl
!;
}
else
{
throwToolExit
(
'"
${debuggingOptions.webLaunchUrl}
" is not a vaild HTTP URL.'
);
}
}
else
{
url
=
platformArgs
[
'uri'
]!
as
String
;
}
final
bool
launchChrome
=
platformArgs
[
'no-launch-chrome'
]
!=
true
;
if
(
launchChrome
)
{
_chrome
=
await
chromeLauncher
.
launch
(
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
3138cce7
...
...
@@ -594,6 +594,30 @@ void main() {
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'fails when "--web-launch-url" is not supported'
,
()
async
{
final
RunCommand
command
=
RunCommand
();
await
expectLater
(
()
=>
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--web-launch-url=http://flutter.dev'
,
]),
throwsA
(
isException
.
having
(
(
Exception
exception
)
=>
exception
.
toString
(),
'toString'
,
isNot
(
contains
(
'web-launch-url'
)),
)),
);
final
DebuggingOptions
options
=
await
command
.
createDebuggingOptions
(
true
);
expect
(
options
.
webLaunchUrl
,
'http://flutter.dev'
);
final
RegExp
pattern
=
RegExp
(
r'^((http)?:\/\/)[^\s]+'
);
expect
(
pattern
.
hasMatch
(
options
.
webLaunchUrl
),
true
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Logger:
()
=>
BufferLogger
.
test
(),
});
}
class
FakeDeviceManager
extends
Fake
implements
DeviceManager
{
...
...
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