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.