パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.1.0

phone_info

詳細な携帯端末のハードウェアおよびネットワーク情報を取得する強力なFlutterプラグインで、デバイスアーキテクチャ(CPU、ABI)、ネットワーク状態(IP、接続タイプ)およびその他の重要なメトリクスを含む。デバッグ、分析、動的機能処理に最適です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
14
いいね数
4
Pub ポイント
140

パッケージをインストール

flutter pub add phone_info

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Phone_Info は、モバイルおよびデスクトップデバイスの CPU アーキテクチャ、ABI、IP アドレス、接続タイプなどを含む、包括的なハードウェアおよびネットワーク情報を提供する Flutter プラグインです。開発者が Android、iOS、Web、macOS、Windows、Linux プラットフォームでデバッグ、分析、適応型機能配信に必要な重要なデバイスメトリクスを収集できるようにします。一貫した API を通じて低レベルのシステム情報へのアクセスを簡素化し、ランタイム診断やパフォーマンス監視に最適です。

用途

  • デバイス固有の問題のデバッグ
  • 分析データの収集
  • 動的機能トグルの有効化
  • ネットワーク接続の監視
  • デバイスタイプに応じたアプリ動作の最適化
  • 複数プラットフォーム間でのアプリケーション互換性のテスト

主な機能

  • 複数のプラットフォーム(Android、iOS、Web、macOS、Windows、Linux)をサポートしています
  • CPUアーキテクチャおよびABIの詳細を取得する
  • リアルタイムでのネットワーク状態とIPアドレスを提供します
  • デバイス情報用のシンプルで統合された API
  • 軽量で統合が簡単
  • さまざまなオペレーティングシステム環境で信頼できるデータを提供します

適している対象

  • クロスプラットフォームアプリを開発する開発者
  • 詳細なデバイス分析が必要なチーム
  • アダプティブUIまたは機能ロジックを必要とするアプリ
  • デバッグツールおよび診断ユーティリティ
  • ネットワーク依存機能を扱うアプリケーション

注意事項

  • AndroidおよびiOSで適切なプラットフォーム権限が必要です
  • 利用可能なシステムレベルのデータに限定
  • 機器の機密情報を漏洩する可能性があります
  • ユーザー向けのプライバシーに敏感なディスプレイには使用しないでください
  • 頻繁な呼び出し中にパフォーマンスへの影響は最小限ですが存在します

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Phone Info

A Flutter plugin for retrieving detailed phone information on Android devices, including network status, device details, battery information, sensors, and comprehensive system specifications. This plugin provides a flexible API to fetch all information at once or individual pieces as needed, making it ideal for apps requiring device or network insights.

Pub Version License: MIT

Features

  • Network Information:
    • Check if the device is connected to a network (isConnected).
    • Get the connection type (Wi-Fi, Mobile Data, or None).
    • Retrieve the network operator name (e.g., "Robi").
    • Get Wi-Fi signal strength in RSSI (dBm).
    • Access detailed network data (local IP, DNS, network type).
  • Device Information:
    • Device name (e.g., "realme C61").
    • Manufacturer (e.g., "realme").
    • Model (e.g., "RMX3930").
    • Operating system version (e.g., "14").
    • Architecture (e.g., "aarch64").
    • Unique device ID.
    • Total memory (RAM) in MB.
    • Available storage in MB.
  • Battery Information:
    • Battery level percentage.
    • Charging status.
    • Battery health.
    • Temperature.
    • Real-time battery status updates via event streams.
  • Hardware Information:
    • CPU details (core count, frequency, load average).
    • Screen specifications (resolution, density, refresh rate, HDR support).
    • Sensor list with detailed information.
    • Storage details (internal and external).
    • Camera specifications.
    • Biometric capabilities.
  • System Information:
    • SIM card details.
    • System health metrics.
    • Accessibility services.
    • Security information (root detection, encryption status).
    • App usage statistics.
  • Flexible API: Fetch all information in a single call or retrieve individual pieces as needed.
  • Error Handling: Gracefully handles permission denials and unavailable data.

Platform Support

Platform Supported Notes
Android ✅ Fully supported (API 21+).
iOS ❌ iOS support not yet implemented (contributions welcome!).

Installation

Add the phone_info to your pubspec.yaml:

dependencies:
  phone_info: ^0.1.0

Run the following command to install the plugin:

flutter pub get
Android Setup
  1. Permissions: Add the following permissions to your app's android/app/src/main/AndroidManifest.xml:

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    
  2. Runtime Permissions: For certain features, request permissions at runtime using a package like permission_handler:

  • READ_PHONE_STATE for network operator information
  • PACKAGE_USAGE_STATS for app usage statistics (requires special approval from user)

Usage

Basic Example

Below is a simple Flutter app demonstrating how to use the plugin to fetch phone information:

import 'package:flutter/material.dart';
import 'package:phone_info/phone_info.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const PhoneInfoScreen(),
    );
  }
}

class PhoneInfoScreen extends StatefulWidget {
  const PhoneInfoScreen({super.key});

  @override
  _PhoneInfoScreenState createState() => _PhoneInfoScreenState();
}

class _PhoneInfoScreenState extends State<PhoneInfoScreen> {
  String _output = 'Press a button to fetch info';

  Future<void> _requestPermissions() async {
    await Permission.phone.request();
  }

  @override
  void initState() {
    super.initState();
    _requestPermissions();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Phone Info Plugin')),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Text(_output, style: const TextStyle(fontSize: 16)),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: () async {
                try {
                  final info = await PhoneInfoPlugin.getPhoneInfo();
                  setState(() {
                    _output = 'All Info: $info';
                  });
                } catch (e) {
                  setState(() {
                    _output = 'Error: $e';
                  });
                }
              },
              child: const Text('Get All Phone Info'),
            ),
            ElevatedButton(
              onPressed: () async {
                try {
                  final deviceName = await PhoneInfoPlugin.getDeviceName();
                  setState(() {
                    _output = 'Device Name: $deviceName';
                  });
                } catch (e) {
                  setState(() {
                    _output = 'Error: $e';
                  });
                }
              },
              child: const Text('Get Device Name'),
            ),
            ElevatedButton(
              onPressed: () async {
                try {
                  final batteryInfo = await PhoneInfoPlugin.getBatteryInfo();
                  setState(() {
                    _output = 'Battery Info: $batteryInfo';
                  });
                } catch (e) {
                  setState(() {
                    _output = 'Error: $e';
                  });
                }
              },
              child: const Text('Get Battery Info'),
            ),
          ],
        ),
      ),
    );
  }
}
Streaming Battery Updates

The plugin also supports streaming real-time battery updates:

import 'package:flutter/material.dart';
import 'package:phone_info/phone_info.dart';

class BatteryMonitorScreen extends StatefulWidget {
  const BatteryMonitorScreen({super.key});

  @override
  _BatteryMonitorScreenState createState() => _BatteryMonitorScreenState();
}

class _BatteryMonitorScreenState extends State<BatteryMonitorScreen> {
  Map<String, dynamic>? _batteryInfo;
  late Stream<Map<String, dynamic>> _batteryStream;

  @override
  void initState() {
    super.initState();
    _batteryStream = PhoneInfoPlugin.batteryInfoStream();
    _batteryStream.listen((batteryInfo) {
      setState(() {
        _batteryInfo = batteryInfo;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Battery Monitor')),
      body: Center(
        child: _batteryInfo == null
            ? const CircularProgressIndicator()
            : Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('Battery Level: ${_batteryInfo!['batteryLevel']}%'),
                  Text('Status: ${_batteryInfo!['isCharging'] ? 'Charging' : 'Not Charging'}'),
                  Text('Health: ${_batteryInfo!['health']}'),
                  Text('Temperature: ${_batteryInfo!['temperature']}°C'),
                ],
              ),
      ),
    );
  }
}

Complete Example

For a complete working example, see the example app.

Example Output

When you press the buttons, you'll see output like:

All Info: {isConnected: true, connectionType: Wi-Fi, networkOperator: Robi, signalStrength: -32, deviceName: realme C61, manufacturer: realme, model: RMX3930, osVersion: 14, architecture: aarch64, deviceId: d55d784905cd7b6e, totalMemory: 26, availableStorage: 86325, batteryInfo: {batteryLevel: 85, isCharging: true, health: Good, temperature: 30.2}, cpuInfo: {coreCount: 8, maxFrequency: 2400, loadAverage: 1.2}, ...}

Battery Info: {batteryLevel: 85, isCharging: true, health: Good, temperature: 30.2}

API Reference

The PhoneInfoPlugin class provides the following methods:

Basic Information
Method Return Type Description
getPhoneInfo() Future<Map<String, dynamic>?> Retrieves all phone information in a single call.
getPlatformVersion() Future<String?> Gets the Android OS version (e.g., "Android 14").
getIsConnected() Future<bool?> Checks if the device is connected to a network.
getConnectionType() Future<String?> Gets the connection type (Wi-Fi, Mobile Data, None).
getNetworkOperator() Future<String?> Gets the network operator name (requires READ_PHONE_STATE).
getSignalStrength() Future<int?> Gets the Wi-Fi signal strength in RSSI (dBm).
getDeviceName() Future<String?> Gets the device name (e.g., "realme C61").
getManufacturer() Future<String?> Gets the manufacturer (e.g., "realme").
getModel() Future<String?> Gets the device model (e.g., "RMX3930").
getOsVersion() Future<String?> Gets the OS version (e.g., "14").
getArchitecture() Future<String?> Gets the device architecture (e.g., "aarch64").
getDeviceId() Future<String?> Gets the unique device ID.
getTotalMemory() Future<int?> Gets the total memory in MB.
getAvailableStorage() Future<int?> Gets the available storage in MB.
Advanced Information
Method Return Type Description
getBatteryInfo() Future<Map<String, dynamic>?> Gets detailed battery information.
getCpuInfo() Future<Map<String, dynamic>?> Gets CPU details (cores, frequency, load).
getNetworkInfo() Future<Map<String, dynamic>?> Gets detailed network information (IP, DNS, etc.).
getScreenInfo() Future<Map<String, dynamic>?> Gets screen specifications.
getSensorInfo() Future<List<Map<String, dynamic>>?> Gets list of device sensors with details.
getStorageInfo() Future<Map<String, dynamic>?> Gets detailed storage information.
getCameraInfo() Future<List<Map<String, dynamic>>?> Gets camera specifications.
getBiometricInfo() Future<Map<String, dynamic>?> Gets biometric capabilities.
getSimInfo() Future<Map<String, dynamic>?> Gets SIM card details.
getSystemHealth() Future<Map<String, dynamic>?> Gets system health metrics.
getAccessibilityInfo() Future<List<String>?> Gets installed accessibility services.
getSecurityInfo() Future<Map<String, dynamic>?> Gets security information (root detection, etc.).
getAppUsageStats() Future<List<Map<String, dynamic>>?> Gets app usage statistics (requires special permission).
Event Streams
Method Return Type Description
batteryInfoStream() Stream<Map<String, dynamic>> Streams real-time battery updates.
Notes
  • All methods are asynchronous and return Futures. Use await to get the result ( e.g., await PhoneInfoPlugin.getDeviceName()).
  • Methods that may fail due to permissions (e.g., getNetworkOperator) return null if the data is unavailable.
  • Wrap method calls in try-catch blocks to handle potential platform exceptions.

Permissions

The plugin requires the following Android permissions:

Permission Purpose Runtime Permission Required?
ACCESS_WIFI_STATE Access Wi-Fi signal strength No
ACCESS_NETWORK_STATE Check network connection status No
READ_PHONE_STATE Get network operator name Yes (Android 6.0+)
PACKAGE_USAGE_STATS Get app usage statistics Yes (special approval)
Requesting Runtime Permissions

Use the permission_handler package to request permissions at runtime:

import 'package:permission_handler/permission_handler.dart';

Future<void> requestPermissions() async {
  if (await Permission.phone.request().isGranted) {
    // Permission granted
  } else {
    // Handle permission denial
  }
  
  // For app usage stats (special permission)
  if (await Permission.systemAppInfo.request().isGranted) {
    // Permission granted
  } else {
    // Direct user to settings
    await openAppSettings();
  }
}

Troubleshooting

  • MissingPluginException: If you see No implementation found for method ..., ensure the plugin is properly built:
    • Run flutter clean and flutter pub get in both the plugin and app directories.
    • Rebuild the app with flutter run.
  • Instance of 'Future<String?>': Ensure you use await when calling asynchronous methods ( e.g., await PhoneInfoPlugin.getDeviceName()).
  • Null Values: If methods like getNetworkOperator return null, check that the required permissions are granted.
  • Build Failures: Ensure your android/build.gradle includes androidx.core:core-ktx:1.12.0 and the correct Kotlin version (e.g., 1.8.22 or later).
  • App Usage Stats Not Working: This requires special permission. Guide users to enable it in settings:
    // Check if permission is granted
    if (!(await Permission.systemAppInfo.isGranted)) {
      // Open settings
      await openAppSettings();
    }
    

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature).
  3. Make your changes and commit (git commit -m 'Add your feature').
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a Pull Request.

Please include tests and update the documentation for new features.

License

This plugin is licensed under the MIT License.

Contact

For issues or feature requests, please open an issue on the GitHub repository.

カテゴリー

依存関係

依存関係一覧 2 件

  • plugin_platform_interface^2.0.2
  • web^1.0.0

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。