diff --git a/packages/flutter_tools/lib/src/commands/listen.dart b/packages/flutter_tools/lib/src/commands/listen.dart index 78be96b2eb..f636b3f3b0 100644 --- a/packages/flutter_tools/lib/src/commands/listen.dart +++ b/packages/flutter_tools/lib/src/commands/listen.dart @@ -11,8 +11,8 @@ import 'start.dart'; class ListenCommand extends StartCommandBase { final String name = 'listen'; - final String description = 'Listen for changes to files and reload the running app on all connected devices. (Android only.)' - 'By default, only listens to "./" and "./lib/". To listen to additional directories, list them on the command line.'; + final String description = 'Listen for changes to files and reload the running app on all connected devices (Android only).' + ' By default, only listens to "./" and "./lib/". To listen to additional directories, list them on the command line.'; /// Only run once. Used for testing. final bool singleRun; diff --git a/packages/flutter_tools/lib/src/commands/start.dart b/packages/flutter_tools/lib/src/commands/start.dart index e01e26acbd..661d68200e 100644 --- a/packages/flutter_tools/lib/src/commands/start.dart +++ b/packages/flutter_tools/lib/src/commands/start.dart @@ -46,7 +46,12 @@ abstract class StartCommandBase extends FlutterCommand { } } - Future startApp({ bool stop: true, bool install: true, bool poke: false }) async { + Future startApp({ + bool stop: true, + bool install: true, + bool poke: false, + bool clearLogs: false + }) async { String mainPath = findMainDartFile(argResults['target']); if (!FileSystemEntity.isFileSync(mainPath)) { @@ -63,7 +68,7 @@ abstract class StartCommandBase extends FlutterCommand { stopper.inheritFromParent(this); stopper.stop(); } - + if (install) { logging.fine('Running install command.'); InstallCommand installer = new InstallCommand(); @@ -90,7 +95,8 @@ abstract class StartCommandBase extends FlutterCommand { poke: poke, checked: argResults['checked'], traceStartup: argResults['trace-startup'], - route: argResults['route'])) + route: argResults['route'], + clearLogs: clearLogs)) startedSomething = true; } ); @@ -110,12 +116,15 @@ abstract class StartCommandBase extends FlutterCommand { class StartCommand extends StartCommandBase { final String name = 'start'; - final String description = 'Start your Flutter app on attached devices. (Android only.)'; + final String description = 'Start your Flutter app on attached devices (Android only).'; StartCommand() { argParser.addFlag('poke', negatable: false, help: 'Restart the connection to the server.'); + argParser.addFlag('clear-logs', + defaultsTo: true, + help: 'Clear log history before starting the app.'); } @override @@ -128,9 +137,10 @@ class StartCommand extends StartCommandBase { ]); bool poke = argResults['poke']; + bool clearLogs = argResults['clear-logs']; // Only stop and reinstall if the user did not specify a poke - int result = await startApp(stop: !poke, install: !poke, poke: poke); + int result = await startApp(stop: !poke, install: !poke, poke: poke, clearLogs: clearLogs); logging.fine('Finished start command.'); return result; diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 651a3e33ca..0cf6a31c6e 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -776,10 +776,11 @@ class AndroidDevice extends Device { } bool startBundle(AndroidApk apk, String bundlePath, { - bool poke, - bool checked, - bool traceStartup, - String route + bool poke: false, + bool checked: true, + bool traceStartup: false, + String route, + bool clearLogs: false }) { logging.fine('$this startBundle'); @@ -791,6 +792,9 @@ class AndroidDevice extends Device { if (!poke) _forwardObservatoryPort(); + if (clearLogs) + this.clearLogs(); + String deviceTmpPath = '/data/local/tmp/dev.flx'; runCheckedSync(adbCommandForDevice(['push', bundlePath, deviceTmpPath])); List cmd = adbCommandForDevice([ @@ -801,7 +805,7 @@ class AndroidDevice extends Device { if (checked) cmd.addAll(['--ez', 'enable-checked-mode', 'true']); if (traceStartup) - cmd.addAll(['--ez', 'trace-startup', 'true']); + cmd.addAll(['--ez', 'trace-startup', 'true']); if (route != null) cmd.addAll(['--es', 'route', route]); cmd.add(apk.launchActivity);