stop.dart 981 Bytes
Newer Older
1 2 3 4 5 6
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

7 8
import '../application_package.dart';
import '../device.dart';
9
import '../runner/flutter_command.dart';
10

11 12 13
class StopCommand extends FlutterCommand {
  final String name = 'stop';
  final String description = 'Stop your Flutter app on all attached devices.';
14 15

  @override
16
  Future<int> runInProject() async {
17 18
    await downloadApplicationPackagesAndConnectToDevices();
    return await stop() ? 0 : 2;
19 20
  }

21
  Future<bool> stop() async {
22 23
    bool stoppedSomething = false;

24 25 26 27 28 29
    for (Device device in devices.all) {
      ApplicationPackage package = applicationPackages.getPackageForPlatform(device.platform);
      if (package == null || !device.isConnected())
        continue;
      if (await device.stopApp(package))
        stoppedSomething = true;
30 31
    }

32 33 34
    return stoppedSomething;
  }
}