device_package_info_manager 1.0.1
device_package_info_manager: ^1.0.1 copied to clipboard
A comprehensive Flutter package for managing device and package information across Flutter applications.
Device & Package Info Manager #
A comprehensive Flutter package for managing device and package information across Flutter applications. This package provides clean, type-safe interfaces for accessing both package and device information with comprehensive utilities for version comparison, validation, and more.
Features #
π¦ Package Information Management #
- Complete Package Info: App name, version, build number, installer store, SDK versions
- Version Utilities: Display version, pre-release detection, version comparison
- Installation Info: Install time, update time, formatted dates
- Validation: Package info validation with detailed version comparison
- Safe Access: Null-safe getters with fallback values
π± Device Information Management #
- Device Details: Model, manufacturer, brand, device type detection
- System Info: OS version, platform details, kernel information
- Hardware Specs: Architecture support, supported ABIs
- Platform Detection: Android, iOS, Web, Windows, macOS, Linux support
- Device Types: Mobile, tablet, desktop, TV, watch, web detection
- System Features: Hardware capabilities and feature detection
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
device_package_info_manager: ^1.0.0
Then run:
flutter pub get
Quick Start #
Package Information #
import 'package:device_package_info_manager/device_package_info_manager.dart';
void main() async {
final packageManager = PackageInfoManagerImpl();
// Get complete package info
final packageInfo = await packageManager.getPackageInfo();
print('App: ${packageInfo.safeAppName}');
print('Version: ${packageInfo.displayVersion}');
print('Full Version: ${packageInfo.fullVersionString}');
// Check version properties
print('Is Pre-release: ${packageInfo.isPreRelease}');
print('Has Valid Version: ${packageInfo.hasValidVersion}');
// Version comparison
final otherPackageInfo = AppPackageInfo.empty();
print('Is Newer: ${packageInfo.isNewerThan(otherPackageInfo)}');
}
Device Information #
import 'package:device_package_info_manager/device_package_info_manager.dart';
void main() async {
final deviceManager = DeviceInfoManagerImpl();
// Get complete device info
final deviceInfo = await deviceManager.getDeviceInfo();
print('Device: ${deviceInfo.displayName}');
print('Manufacturer: ${deviceInfo.manufacturer}');
print('OS: ${deviceInfo.fullDeviceInfo}');
// Check device properties
print('Is Physical Device: ${deviceInfo.isPhysicalDevice}');
print('Device Type: ${deviceInfo.deviceType}');
print('Supports ARM64: ${deviceInfo.supportsArm64}');
}
API Reference #
PackageInfoManager #
Core Methods
// Get complete package information
Future<AppPackageInfo> getPackageInfo()
// Get specific package details
Future<String> getAppName()
Future<String> getVersion()
Future<String> getBuildNumber()
Future<String> getPackageName()
DeviceInfoManager #
Core Methods
// Get complete device information
Future<AppDeviceInfo> getDeviceInfo()
// Get specific device details
Future<String> getDeviceName()
Future<String> getDeviceModel()
Future<String> getManufacturer()
Future<String> getBrand()
Future<String> getOsVersion()
Future<DeviceType> getDeviceType()
// Platform detection
Future<bool> isPhysicalDevice()
Future<bool> isAndroid()
Future<bool> isIOS()
Future<bool> isWeb()
Future<bool> isDesktop()
Models #
AppPackageInfo #
class AppPackageInfo extends BaseDataModel<AppPackageInfo> {
final String? appName;
final String? packageName;
final String? version;
final String? buildNumber;
final String? buildSignature;
final String? installerStore;
final DateTime? installTime;
final DateTime? updateTime;
final bool isSystemApp;
final int versionCode;
final String? targetSdkVersion;
final String? minSdkVersion;
// Utility getters
String get safeAppName; // Safe app name with fallback
String get displayVersion; // Formatted version display
String get fullVersionString; // Complete version + build number
String get displayName; // App name or package name
bool get isPreRelease; // Detects pre-release versions
bool get hasValidVersion; // Validates version format
bool get isInstalled; // Checks if package is installed
String get installDateFormatted; // Formatted install date
String get updateDateFormatted; // Formatted update date
// Version comparison methods
bool isNewerThan(AppPackageInfo other);
bool isOlderThan(AppPackageInfo other);
bool isSameVersionAs(AppPackageInfo other);
int compareTo(AppPackageInfo other);
}
AppDeviceInfo #
class AppDeviceInfo extends BaseDataModel<AppDeviceInfo> {
// Basic device information
final String deviceId;
final String deviceName;
final String deviceModel;
final String manufacturer;
final String brand;
final String product;
// Operating system information
final String osVersion;
final String osName;
final String platformVersion;
final String platformName;
// Device characteristics
final DeviceType deviceType;
final bool isPhysicalDevice;
final bool isEmulator;
final bool isTablet;
final bool isMobile;
final bool isDesktop;
// Technical specifications
final String? sdkVersion;
final String? kernelVersion;
final String? architecture;
final List<String> systemFeatures;
final List<String> supportedAbis;
final List<String> supported32BitAbis;
final List<String> supported64BitAbis;
// Platform-specific fields
final String? systemName; // iOS
final String? systemVersion; // iOS
final String? identifierForVendor; // iOS
final Map<String, String> utsname; // Linux/macOS
// Utility getters
String get displayName; // Formatted device display name
String get fullDeviceInfo; // Complete device information
bool get supportsArm64; // ARM64 architecture support
bool get supportsArm32; // ARM32 architecture support
bool get supportsX86; // x86 architecture support
bool get isUnknownDevice; // Unknown device detection
}
DeviceType Enum #
enum DeviceType {
unknown, // Unable to determine device type
mobile, // Mobile phones
tablet, // Tablet devices
desktop, // Desktop computers
tv, // Smart TVs
watch, // Smartwatches
web, // Web browsers
}
Advanced Usage #
Version Comparison #
final packageManager = PackageInfoManagerImpl();
final currentPackage = await packageManager.getPackageInfo();
// Create a reference package for comparison
final targetPackage = AppPackageInfo(
appName: 'MyApp',
version: '2.0.0',
buildNumber: '200',
// ... other fields
);
// Compare versions
if (currentPackage.isOlderThan(targetPackage)) {
print('Update available!');
} else if (currentPackage.isNewerThan(targetPackage)) {
print('You have a newer version');
} else {
print('Versions are the same');
}
// Sort packages by version
final packages = <AppPackageInfo>[/* ... */];
packages.sort((a, b) => a.compareTo(b));
Device Capability Detection #
final deviceManager = DeviceInfoManagerImpl();
final deviceInfo = await deviceManager.getDeviceInfo();
// Check architecture support
if (deviceInfo.supportsArm64) {
print('Device supports 64-bit ARM architecture');
// Load ARM64 optimized assets
}
// Platform-specific logic
switch (deviceInfo.deviceType) {
case DeviceType.mobile:
// Mobile-specific UI
break;
case DeviceType.tablet:
// Tablet-optimized layout
break;
case DeviceType.desktop:
// Desktop interface
break;
default:
// Default fallback
}
// Feature detection
if (deviceInfo.systemFeatures.contains('android.hardware.camera')) {
print('Device has camera support');
}
Error Handling #
try {
final packageInfo = await packageManager.getPackageInfo();
print('Package loaded successfully: ${packageInfo.safeAppName}');
} catch (e) {
print('Failed to load package info: $e');
// Use fallback or show error to user
}
// Safe data access with fallbacks
final deviceInfo = await deviceManager.getDeviceInfo();
final safeName = deviceInfo.displayName; // Always returns a valid string
final safeModel = deviceInfo.deviceModel.isNotEmpty
? deviceInfo.deviceModel
: 'Unknown Model';
Platform Support #
Platform | Package Info | Device Info | Specific Features |
---|---|---|---|
Android | β Full | β Full | SDK version, supported ABIs, system features |
iOS | β Full | β Full | System name/version, identifier for vendor |
Web | β Full | β Limited | Browser info, limited device details |
Windows | β Full | β Full | Windows-specific system information |
macOS | β Full | β Full | macOS system details, utsname info |
Linux | β Full | β Full | Linux distribution and system details |
Requirements #
- Flutter SDK: >= 3.8.1
- Dart SDK: >= 3.8.1
Dependencies #
This package uses the following trusted dependencies:
package_info_plus
^8.3.0 - Package information accessdevice_info_plus
^11.5.0 - Device information accessflutter_shared_utilities
^1.0.2 - Base utilities and extensions
Example #
Check out the /example
folder for a comprehensive demo app that showcases all features:
cd example
flutter run
The example app demonstrates:
- π± Complete package information display
- π§ Device specifications viewer
- π Version comparison tools
- ποΈ Platform detection examples
- π οΈ Error handling patterns
Testing #
This package includes comprehensive tests. Run them with:
flutter test
Contributing #
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Please read our contributing guidelines for more details.
Issues & Support #
- π Bug Reports: GitHub Issues
- π¬ Questions: GitHub Discussions
- π§ Contact: Open an issue for direct support
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog #
See CHANGELOG.md for a detailed list of changes and version history.