package_info_kit 0.0.1
package_info_kit: ^0.0.1 copied to clipboard
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 an [...]
package_info_kit #
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 namepackageName- The package nameversion- The package versionbuildNumber- The build numberbuildSignature- The build signature (Android)installerStore- The installer store informationinstallTime- The time when the application was installedupdateTime- The time when the application was last updatedandroidVersion- The Android version (e.g., "12", "13") - Android onlyandroidSdkVersion- The Android SDK version (e.g., 31, 33) - Android onlyandroidCodename- The Android codename (e.g., "REL") - Android only
Methods
PackageInfo.fromPlatform()- Retrieves package information from the platformPackageInfo.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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Author #
ItsAQibDev
- GitHub: @itsaqibdev
- Website: itsaqibdev.me