flutter_device_inspector 0.0.2
flutter_device_inspector: ^0.0.2 copied to clipboard
A Flutter plugin to inspect device details like model, RAM, CPU info, OS version, and more.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_device_inspector/flutter_device_inspector.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
DeviceInfo? _deviceInfo;
bool _isLoading = true;
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
try {
final info = await FlutterDeviceInspector.getFullInfo();
if (!mounted) return;
setState(() {
_deviceInfo = info;
_isLoading = false;
});
} catch (e) {
debugPrint('Device info error: $e');
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.deepPurple,
),
home: Scaffold(
appBar: AppBar(
title: const Text('Device Inspector'),
centerTitle: true,
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
_deviceHeader(),
const SizedBox(height: 16),
Expanded(child: _deviceInfoCard()),
const SizedBox(height: 12),
_refreshButton(),
],
),
),
),
);
}
/// -------- HEADER --------
Widget _deviceHeader() {
return Row(
children: [
CircleAvatar(
radius: 28,
backgroundColor: Colors.deepPurple.withValues(alpha:0.15),
child: const Icon(
Icons.phone_android,
size: 30,
color: Colors.deepPurple,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_deviceInfo?.model ?? 'Unknown Device',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Text(
_deviceInfo?.manufacturer ?? '',
style: TextStyle(
color: Colors.grey.shade600,
),
),
],
),
),
],
);
}
/// -------- INFO CARD --------
Widget _deviceInfoCard() {
return Card(
elevation: 3,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
_infoRow(Icons.fingerprint, 'Device ID', _deviceInfo?.deviceId),
_divider(),
_infoRow(Icons.branding_watermark, 'Brand', _deviceInfo?.brand),
_divider(),
_infoRow(Icons.system_update, 'OS Version', _deviceInfo?.osVersion),
_divider(),
_infoRow(Icons.memory, 'RAM', _deviceInfo?.ram),
_divider(),
_infoRow(Icons.storage, 'Storage', _deviceInfo?.totalStorage),
_divider(),
_infoRow(Icons.developer_board, 'CPU', _deviceInfo?.cpu),
],
),
),
);
}
Widget _infoRow(IconData icon, String title, String? value) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, size: 22, color: Colors.deepPurple),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Colors.deepPurple,
),
),
const SizedBox(height: 4),
Text(
value ?? 'Unknown',
style: const TextStyle(fontSize: 15),
),
],
),
),
],
);
}
Widget _divider() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Divider(color: Colors.grey.shade300),
);
}
/// -------- BUTTON --------
Widget _refreshButton() {
return SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
onPressed: initPlatformState,
icon: const Icon(Icons.refresh),
label: const Text('Refresh Device Info'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
);
}
}