package_info_kit

Pub License

A comprehensive Flutter package for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android. Enhanced with additional features like install time and update time information.

๐ŸŒŸ Features

  • ๐Ÿ“ฑ App Information: Get app name, package name, version, and build number
  • ๐Ÿ” Security: Retrieve build signature (Android)
  • ๐Ÿ›’ Distribution: Get installer store information
  • โฐ Timeline: Access install time and update time
  • ๐Ÿค– Android Specific: Get Android version, SDK version, and codename
  • ๐Ÿ”„ Cross-platform: Support for Android, iOS, and macOS
  • ๐Ÿงช Testing: Built-in support for mock values in tests
  • ๐Ÿ“ฆ Easy Integration: Simple API with static convenience methods

๐Ÿš€ Platform Support

Android iOS macOS Web Linux Windows
โœ… โœ… โœ… โณ โณ โณ

โœ… = Implemented
โณ = Coming soon

๐Ÿ“ฆ Installation

Add package_info_kit as a dependency in your pubspec.yaml file:

dependencies:
  package_info_kit: ^0.0.1

Then run:

flutter pub get

๐Ÿ› ๏ธ Usage

Basic Usage

Import the package in your Dart code:

import 'package:package_info_kit/package_info_kit.dart';

Get package information:

// Be sure to add this line if `PackageInfo.fromPlatform()` is called before runApp()
WidgetsFlutterBinding.ensureInitialized();

PackageInfo packageInfo = await PackageInfo.fromPlatform();

String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
String buildSignature = packageInfo.buildSignature;
String? installerStore = packageInfo.installerStore;
DateTime? installTime = packageInfo.installTime;
DateTime? updateTime = packageInfo.updateTime;

// New Android-specific features
String? androidVersion = packageInfo.androidVersion;
int? androidSdkVersion = packageInfo.androidSdkVersion;
String? androidCodename = packageInfo.androidCodename;

Complete Example

import 'package:flutter/material.dart';
import 'package:package_info_kit/package_info_kit.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Package Info Kit Demo',
      home: Scaffold(
        appBar: AppBar(title: const Text('Package Info Kit Demo')),
        body: FutureBuilder<PackageInfo>(
          future: PackageInfo.fromPlatform(),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              PackageInfo info = snapshot.data!;
              return ListView(
                children: [
                  ListTile(title: const Text('App Name'), subtitle: Text(info.appName)),
                  ListTile(title: const Text('Package Name'), subtitle: Text(info.packageName)),
                  ListTile(title: const Text('Version'), subtitle: Text(info.version)),
                  ListTile(title: const Text('Build Number'), subtitle: Text(info.buildNumber)),
                  // Android-specific information
                  if (info.androidVersion != null)
                    ListTile(title: const Text('Android Version'), subtitle: Text(info.androidVersion!)),
                  if (info.androidSdkVersion != null)
                    ListTile(title: const Text('Android SDK Version'), subtitle: Text(info.androidSdkVersion.toString())),
                ],
              );
            } else if (snapshot.hasError) {
              return Text('Error: ${snapshot.error}');
            }
            return const CircularProgressIndicator();
          },
        ),
      ),
    );
  }
}

๐Ÿงช Testing

For testing purposes, you can set mock values:

void main() {
  test('mock package info', () {
    PackageInfo.setMockInitialValues(
      appName: 'Mock App',
      packageName: 'com.example.mock',
      version: '1.0.0',
      buildNumber: '1',
      buildSignature: 'mock-signature',
      installerStore: 'play_store',
      androidVersion: '13',
      androidSdkVersion: 33,
      androidCodename: 'REL',
    );
    
    // Your tests here
  });
}

๐Ÿ“š API Reference

PackageInfo Class

Main class for accessing package information.

Properties

  • appName - The app name
  • packageName - The package name
  • version - The package version
  • buildNumber - The build number
  • buildSignature - The build signature (Android)
  • installerStore - The installer store information
  • installTime - The time when the application was installed
  • updateTime - The time when the application was last updated
  • androidVersion - The Android version (e.g., "12", "13") - Android only
  • androidSdkVersion - The Android SDK version (e.g., 31, 33) - Android only
  • androidCodename - The Android codename (e.g., "REL") - Android only

Methods

  • PackageInfo.fromPlatform() - Retrieves package information from the platform
  • PackageInfo.setMockInitialValues() - Sets mock values for testing

๐Ÿ†š Comparison with package_info_plus

Feature package_info_kit package_info_plus
App Name โœ… โœ…
Package Name โœ… โœ…
Version โœ… โœ…
Build Number โœ… โœ…
Build Signature โœ… โœ…
Installer Store โœ… โœ…
Install Time โœ… โŒ
Update Time โœ… โŒ
Android Version โœ… โŒ
Android SDK Version โœ… โŒ
Android Codename โœ… โŒ
Web Support โณ โœ…
Linux Support โณ โœ…
Windows Support โณ โœ…

๐Ÿ“ Additional Information

This package is inspired by package_info_plus but extends its functionality with additional features like install time, update time, and Android version information.

For more detailed usage, check out the example provided in the package.

๐Ÿ› Known Issues

  • Web, Linux, and Windows platforms are not yet implemented but will be added in future releases.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘ค Author

ItsAQibDev

Libraries

package_info_kit
A Flutter package for querying information about the application package.