utils.dart 1.17 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6 7 8 9 10 11
import 'package:flutter_tools/src/runner/flutter_command.dart';

typedef CommandFunction = Future<FlutterCommandResult> Function();

class DummyFlutterCommand extends FlutterCommand {

  DummyFlutterCommand({
12
    this.shouldUpdateCache = false,
13
    this.noUsagePath  = false,
14
    this.name = 'dummy',
15
    this.commandFunction,
16
    this.packagesPath,
17
    this.fileSystemScheme,
18
    this.fileSystemRoots = const <String>[],
19 20 21
  });

  final bool noUsagePath;
22
  final CommandFunction? commandFunction;
23 24 25 26 27 28 29 30

  @override
  final bool shouldUpdateCache;

  @override
  String get description => 'does nothing';

  @override
31
  Future<String?> get usagePath async => noUsagePath ? null : super.usagePath;
32 33

  @override
34
  final String name;
35 36 37

  @override
  Future<FlutterCommandResult> runCommand() async {
38
    return commandFunction == null ? FlutterCommandResult.fail() : await commandFunction!();
39
  }
40 41

  @override
42
  final String? packagesPath;
43 44

  @override
45
  final String? fileSystemScheme;
46 47 48

  @override
  final List<String> fileSystemRoots;
49
}