Pass method used to start flutter application (#27812)

This commit is contained in:
Jonah Williams 2019-02-11 18:05:23 -08:00 committed by GitHub
parent b47da6c2b7
commit 23d38901ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View File

@ -109,7 +109,7 @@ The `stop()` command takes one parameter, `appId`. It returns a `bool` to indica
#### app.start
This is sent when an app is starting. The `params` field will be a map with the fields `appId`, `directory`, and `deviceId`.
This is sent when an app is starting. The `params` field will be a map with the fields `appId`, `directory`, `deviceId`, and `launchMode`.
#### app.debugPort

View File

@ -221,6 +221,7 @@ class AttachCommand extends FlutterCommand {
null,
true,
fs.currentDirectory,
LaunchMode.attach,
);
} catch (error) {
throwToolExit(error.toString());

View File

@ -400,6 +400,7 @@ class AppDomain extends Domain {
projectDirectory,
enableHotReload,
cwd,
LaunchMode.run,
);
}
@ -409,7 +410,8 @@ class AppDomain extends Domain {
Device device,
String projectDirectory,
bool enableHotReload,
Directory cwd) async {
Directory cwd,
LaunchMode launchMode) async {
final AppInstance app = AppInstance(_getNewAppId(),
runner: runner, logToStdout: daemon.logToStdout);
_apps.add(app);
@ -417,6 +419,7 @@ class AppDomain extends Domain {
'deviceId': device.id,
'directory': projectDirectory,
'supportsRestart': isRestartSupported(enableHotReload, device),
'launchMode': launchMode.toString(),
});
Completer<DebugConnectionInfo> connectionInfoCompleter;
@ -1021,3 +1024,19 @@ class LogMessage {
final String message;
final StackTrace stackTrace;
}
/// The method by which the flutter app was launched.
class LaunchMode {
const LaunchMode._(this._value);
/// The app was launched via `flutter run`.
static const LaunchMode run = LaunchMode._('run');
/// The app was launched via `flutter attach`.
static const LaunchMode attach = LaunchMode._('attach');
final String _value;
@override
String toString() => _value;
}

View File

@ -42,7 +42,8 @@ Future<void> main() async {
'method': 'app.start',
'params': <String, dynamic> {
'deviceId': words[1],
'projectDirectory': words[2]
'projectDirectory': words[2],
'launchMode': words[3],
}
});
} else if (words.first == 'stop') {