forked from firka/flutter
Expose emulator creation to daemon API (#18905)
* Fix typo * Add emulator.create to Daemon API * Swap order of daemon changelog entries
This commit is contained in:
@@ -28,7 +28,7 @@ import '../runner/flutter_command.dart';
|
||||
import '../tester/flutter_tester.dart';
|
||||
import '../vmservice.dart';
|
||||
|
||||
const String protocolVersion = '0.3.0';
|
||||
const String protocolVersion = '0.4.0';
|
||||
|
||||
/// A server process command. This command will start up a long-lived server.
|
||||
/// It reads JSON-RPC based commands from stdin, executes them, and returns
|
||||
@@ -849,6 +849,7 @@ class EmulatorDomain extends Domain {
|
||||
EmulatorDomain(Daemon daemon) : super(daemon, 'emulator') {
|
||||
registerHandler('getEmulators', getEmulators);
|
||||
registerHandler('launch', launch);
|
||||
registerHandler('create', create);
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEmulators([Map<String, dynamic> args]) async {
|
||||
@@ -868,6 +869,16 @@ class EmulatorDomain extends Domain {
|
||||
await matches.first.launch();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> create(Map<String, dynamic> args) async {
|
||||
final String name = _getStringArg(args, 'name', required: false);
|
||||
final CreateEmulatorResult res = await emulators.createEmulator(name: name);
|
||||
return <String, dynamic>{
|
||||
'success': res.success,
|
||||
'emulatorName': res.emulatorName,
|
||||
'error': res.error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// A [Logger] which sends log messages to a listening daemon client.
|
||||
|
||||
@@ -98,12 +98,15 @@ class EmulatorManager {
|
||||
// - Removes lines that say "null" (!)
|
||||
// - Removes lines that tell the user to use '--force' to overwrite emulators
|
||||
String cleanError(String error) {
|
||||
return (error ?? '')
|
||||
if (error == null || error.trim() == '')
|
||||
return null;
|
||||
return error
|
||||
.split('\n')
|
||||
.where((String l) => l.trim() != 'null')
|
||||
.where((String l) =>
|
||||
l.trim() != 'Use --force if you want to replace it.')
|
||||
.join('\n');
|
||||
.join('\n')
|
||||
.trim();
|
||||
}
|
||||
|
||||
final List<String> args = <String>[
|
||||
|
||||
Reference in New Issue
Block a user