device_package_info_manager 1.0.1 copy "device_package_info_manager: ^1.0.1" to clipboard
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:

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:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

Please read our contributing guidelines for more details.

Issues & 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.

0
likes
0
points
105
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter package for managing device and package information across Flutter applications.

Repository (GitHub)
View/report issues

Topics

#device-info #package-info #platform-info #app-version #app-info

License

unknown (license)

Dependencies

device_info_plus, flutter, flutter_shared_utilities, package_info_plus

More

Packages that depend on device_package_info_manager