phone_info
詳細な携帯端末のハードウェアおよびネットワーク情報を取得する強力なFlutterプラグインで、デバイスアーキテクチャ(CPU、ABI)、ネットワーク状態(IP、接続タイプ)およびその他の重要なメトリクスを含む。デバッグ、分析、動的機能処理に最適です。
Syed-Bipul-Rahman/phone_info open-source repository details.
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0^2.0.2{"sdk":"flutter"}^5.0.0以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
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.
isConnected).Wi-Fi, Mobile Data, or None).| Platform | Supported | Notes |
|---|---|---|
| Android | ✅ | Fully supported (API 21+). |
| iOS | ❌ | iOS support not yet implemented (contributions welcome!). |
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
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"/>
Runtime Permissions: For certain features, request permissions at runtime using a package like permission_handler:
READ_PHONE_STATE for network operator informationPACKAGE_USAGE_STATS for app usage statistics (requires special approval from user)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'),
),
],
),
),
);
}
}
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'),
],
),
),
);
}
}
For a complete working example, see the example app.
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}
The PhoneInfoPlugin class provides the following methods:
| 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. |
| 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). |
| Method | Return Type | Description |
|---|---|---|
batteryInfoStream() |
Stream<Map<String, dynamic>> |
Streams real-time battery updates. |
Futures. Use await to get the result (
e.g., await PhoneInfoPlugin.getDeviceName()).getNetworkOperator) return null if the data is
unavailable.try-catch blocks to handle potential platform exceptions.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) |
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();
}
}
No implementation found for method ..., ensure the plugin
is properly built:
flutter clean and flutter pub get in both the plugin and app directories.flutter run.await when calling asynchronous methods (
e.g., await PhoneInfoPlugin.getDeviceName()).getNetworkOperator return null, check that the required
permissions are granted.android/build.gradle includes androidx.core:core-ktx:1.12.0
and the correct Kotlin version (e.g., 1.8.22 or later).// Check if permission is granted
if (!(await Permission.systemAppInfo.isGranted)) {
// Open settings
await openAppSettings();
}
Contributions are welcome! To contribute:
git checkout -b feature/your-feature).git commit -m 'Add your feature').git push origin feature/your-feature).Please include tests and update the documentation for new features.
This plugin is licensed under the MIT License.
For issues or feature requests, please open an issue on the GitHub repository.