import 'package:package_info_plus/package_info_plus.dart';

class PackageInfoUtil {
  final PackageInfo packageInfo;
  // 私有静态变量，存储唯一实例
  static PackageInfoUtil? _instance;
  // 私有构造函数，防止外部直接创建实例
  PackageInfoUtil._(this.packageInfo) {
    // 初始化代码
  }

  static PackageInfoUtil getInstance([PackageInfo? packageName]) {
    // 如果实例不存在，则创建实例
    _instance ??= PackageInfoUtil._(packageName!);
    return _instance!;
  }

  // 初始化请求配置
  static Future<PackageInfo> init() async {
    var packageInfo = await PackageInfo.fromPlatform();
    return packageInfo;
  }
}
