flutterio_device_kit

Device utilities and services for accessing platform-specific functionality in Flutter mobile applications.

Features

  • DeviceInfoService: Platform detection and device type identification
    • Android and iOS platform detection
    • Phone vs tablet device type detection
    • Operating system version information
    • Comprehensive error handling

Getting Started

Add this package to your pubspec.yaml:

dependencies:
  flutterio_device_kit:
    git:
      url: https://github.com/ibrghoutn/flutterio.git
      path: packages/flutterio_device_kit

Platform Setup

Android

No additional setup required for basic device info functionality.

For future features that may require permissions, you might need to add permissions to your android/app/src/main/AndroidManifest.xml:

<!-- Example for future features -->
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> -->

iOS

No additional setup required for basic device info functionality.

For future features that may require permissions, you might need to add usage descriptions to your ios/Runner/Info.plist:

<!-- Example for future features -->
<!-- <key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs location access to provide location-based features.</string> -->

Usage

DeviceInfoService

Get information about the current device and platform:

import 'package:flutterio_device_kit/flutterio_device_kit.dart';

final deviceInfo = DeviceInfoService();

// Check platform
final platform = await deviceInfo.getPlatform();
switch (platform) {
  case DevicePlatform.android:
    print('Running on Android');
    break;
  case DevicePlatform.ios:
    print('Running on iOS');
    break;
  case DevicePlatform.unknown:
    print('Unknown platform');
    break;
}

// Check device type
final deviceType = await deviceInfo.getDeviceType();
if (deviceType == DeviceType.tablet) {
  print('This is a tablet');
} else {
  print('This is a phone');
}

// Convenience methods
final isTablet = await deviceInfo.isTablet();
final isPhone = await deviceInfo.isPhone();

// Get comprehensive system info
final systemInfo = await deviceInfo.getSystemInfo();
print('Platform: ${systemInfo.platform}');
print('Device Type: ${systemInfo.deviceType}');
print('OS Version: ${systemInfo.osVersion ?? 'Unknown'}');

Error Handling

The service includes comprehensive error handling:

try {
  final systemInfo = await deviceInfo.getSystemInfo();
  // Use systemInfo
} catch (e) {
  // Handle any errors gracefully
  print('Failed to get device info: $e');
}

Service Catalog

Device Information

  • DeviceInfoService: Platform and device type detection

Additional Information

This package is part of the FlutterIO monorepo. For more information, visit the main repository.

The package uses the permission_handler dependency for future features that may require system permissions.

Contributing

Please see our contributing guidelines in the main repository.

Libraries

flutterio_device_kit
Device utilities and services for accessing platform-specific functionality.