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

5
import 'base/context.dart';
6
import 'base/file_system.dart';
7
import 'build_info.dart';
8

9
abstract class ApplicationPackageFactory {
10
  static ApplicationPackageFactory? get instance => context.get<ApplicationPackageFactory>();
11

12
  /// Create an [ApplicationPackage] for the given platform.
13
  Future<ApplicationPackage?> getPackageForPlatform(
14
    TargetPlatform platform, {
15 16
    BuildInfo? buildInfo,
    File? applicationBinary,
17
  });
18 19
}

20
abstract class ApplicationPackage {
21
  ApplicationPackage({ required this.id })
22
    : assert(id != null);
23

24 25 26
  /// Package ID from the Android Manifest or equivalent.
  final String id;

27
  String? get name;
28

29
  String? get displayName => name;
30

31
  @override
32
  String toString() => displayName ?? id;
33
}
34 35 36 37 38 39 40 41 42

/// An interface for application package that is created from prebuilt binary.
abstract class PrebuiltApplicationPackage implements ApplicationPackage {
  /// The application bundle of the prebuilt application.
  ///
  /// The same ApplicationPackage should be able to be recreated by passing
  /// the file to [FlutterApplicationPackageFactory.getPackageForPlatform].
  FileSystemEntity get applicationPackage;
}