system_status_plugin 0.0.1 copy "system_status_plugin: ^0.0.1" to clipboard
system_status_plugin: ^0.0.1 copied to clipboard

PlatformAndroid

A Flutter plugin to get system info like model, board, manufacturer, and screen size.

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:system_status_plugin/system_status_plugin.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'System Status Monitor',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const SystemStatusPage(),
    );
  }
}

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

  @override
  State<SystemStatusPage> createState() => _SystemStatusPageState();
}

class _SystemStatusPageState extends State<SystemStatusPage>
    with TickerProviderStateMixin {
  Map<String, dynamic>? _cpuInfo;
  Map<String, dynamic>? _deviceInfo;
  Map<String, dynamic>? _batteryInfo;
  Map<String, dynamic>? _systemInfo;
  String _gpuVendor = '';
  String _gpuRenderer = '';
  String _gpuLoad = '';
  String _scalingGovernor = '';
  Timer? _timer;
  Timer? _deviceTimer;
  List<String> _clockSpeeds = [];
  String _availableRam = '';
  String _availableStorage = '';
  String _uptime = 'Loading...';

  @override
  void initState() {
    super.initState();
    _fetchSystemStatus();
    _fetchDeviceInfo();
    _fetchSystemInfo();
    _fetchBatteryInfo();
    _timer =
        Timer.periodic(const Duration(seconds: 3), (_) => _fetchSystemStatus());

    _deviceTimer = Timer.periodic(
      const Duration(seconds: 3),
      (_) => _fetchDeviceInfo(),
    );

    SystemStatusPlugin.cpuClockStream.listen((data) {
      if (mounted) {
        setState(() {
          _clockSpeeds = data;
        });
      }
    });
    SystemStatusPlugin.availableRamStream.listen((data) {
      if (mounted) {
        setState(() {
          _availableRam = data;
        });
      }
    });

    SystemStatusPlugin.availableStorageStream.listen((data) {
      if (mounted) {
        setState(() {
          _availableStorage = data;
        });
      }
    });

    SystemStatusPlugin.batteryStream.listen((data) {
      if (mounted) {
        setState(() {
          _batteryInfo = data;
        });
      }
    });

    SystemStatusPlugin.uptimeStream.listen((data) {
      if (mounted) {
        setState(() {
          _uptime = data;
        });
      }
    });
  }

  Future<void> _fetchSystemStatus() async {
    try {
      final cpuInfo = await SystemStatusPlugin.getCpuInfo();
      final gpuVendor = await SystemStatusPlugin.getGpuVendor();
      final gpuRenderer = await SystemStatusPlugin.getGpuRenderer();
      final gpuLoad = await SystemStatusPlugin.getGpuLoad();
      final scalingGovernor = await SystemStatusPlugin.getScalingGovernor();

      if (mounted) {
        setState(() {
          _cpuInfo = cpuInfo;
          _gpuVendor = gpuVendor;
          _gpuRenderer = gpuRenderer;
          _gpuLoad = gpuLoad;
          _scalingGovernor = scalingGovernor;
        });
      }
    } catch (e) {
      debugPrint("Error fetching system info: $e");
    }
  }

  Future<void> _fetchDeviceInfo() async {
    try {
      final info = await SystemStatusPlugin.getDeviceDetails();
      if (mounted) {
        setState(() {
          _deviceInfo = info;
        });
      }
    } catch (e) {
      debugPrint("Error fetching device info: $e");
    }
  }

  Future<void> _fetchBatteryInfo() async {
    try {
      final info = await SystemStatusPlugin.getBatteryInfo();
      if (mounted) {
        setState(() {
          _batteryInfo = info;
        });
      }
    } catch (e) {
      debugPrint("Error fetching device info: $e");
    }
  }

  Future<void> _fetchSystemInfo() async {
    try {
      final info = await SystemStatusPlugin.getSystemInfo();
      if (mounted) {
        setState(() {
          _systemInfo = info;
        });
      }
    } catch (e) {
      debugPrint("Error fetching device info: $e");
    }
  }

  @override
  void dispose() {
    _timer?.cancel();
    _deviceTimer?.cancel();
    super.dispose();
  }

  Widget _infoCard(String title, String? value) {
    return Card(
      elevation: 2,
      margin: const EdgeInsets.symmetric(vertical: 6),
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
      child: ListTile(
        leading: const Icon(Icons.info_outline, color: Colors.blueAccent),
        title: Text(title),
        subtitle: Text(value ?? 'N/A',
            style: const TextStyle(fontWeight: FontWeight.w500)),
      ),
    );
  }

  Widget _buildSdcTab() {
    if (_cpuInfo == null) {
      return const Center(child: CircularProgressIndicator());
    }

    final headlineStyle = Theme.of(context).textTheme.titleLarge!.copyWith(
          fontWeight: FontWeight.bold,
          color: Colors.blueGrey.shade900,
        );

    final labelStyle = Theme.of(context).textTheme.bodyMedium!.copyWith(
          fontWeight: FontWeight.w600,
          color: Colors.blueGrey.shade700,
        );

    final valueStyle = Theme.of(context).textTheme.bodyLarge!.copyWith(
          color: Colors.black87,
        );

    Widget dataRow(String label, String value) {
      return Padding(
        padding: const EdgeInsets.symmetric(vertical: 6.0),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(flex: 2, child: Text("$label:", style: labelStyle)),
            Expanded(flex: 3, child: Text(value, style: valueStyle)),
          ],
        ),
      );
    }

    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
      color: Colors.grey.shade100,
      child: ListView(
        children: [
          Text("CPU Info", style: headlineStyle),
          const SizedBox(height: 12),
          dataRow("Model", _cpuInfo!['model'] ?? 'N/A'),
          dataRow("CPU Details", _cpuInfo!['cpuDetails'] ?? 'N/A'),
          dataRow("Architecture", _cpuInfo!['architecture'] ?? 'N/A'),
          dataRow("Revision", _cpuInfo!['revision'] ?? 'N/A'),
          dataRow("Cores", _cpuInfo!['cores'].toString() ?? 'N/A'),
          dataRow("big.LITTLE", _cpuInfo!['bigLittle'] ?? 'N/A'),
          const SizedBox(height: 28),
          Text("Live CPU Clock Speeds", style: headlineStyle),
          const SizedBox(height: 12),
          ..._clockSpeeds.map((clock) => dataRow("Core", clock)),
          const SizedBox(height: 28),
          Text("Scaling Governor", style: headlineStyle),
          const SizedBox(height: 12),
          dataRow("Governor",
              _scalingGovernor.isNotEmpty ? _scalingGovernor : 'N/A'),
          const SizedBox(height: 28),
          Text("GPU Info", style: headlineStyle),
          const SizedBox(height: 12),
          dataRow("Vendor", _gpuVendor),
          dataRow("Renderer", _gpuRenderer),
          dataRow("GPU Load", _gpuLoad),
        ],
      ),
    );
  }

  Widget _buildDeviceTab() {
    if (_deviceInfo == null) {
      return const Center(child: CircularProgressIndicator());
    }

    final info = _deviceInfo!;
    return ListView(
      padding: const EdgeInsets.all(16),
      children: [
        Text("📱 Device Info",
            style: Theme.of(context).textTheme.headlineMedium),
        const SizedBox(height: 8),
        Text("Model: ${info['model'] ?? 'N/A'}"),
        Text("Manufacturer: ${info['manufacturer'] ?? 'N/A'}"),
        Text("Board: ${info['board'] ?? 'N/A'}"),
        Text("Screen Size: ${info['screenSize'] ?? 'N/A'}"),
        Text("Resolution: ${info['screenResolution'] ?? 'N/A'}"),
        Text("Display: ${info['screenDisplay'] ?? 'N/A'}"),
        const SizedBox(height: 16),
        Text("🧠 Memory", style: Theme.of(context).textTheme.titleMedium),
        Text("Total RAM: ${info['totalRAM'] ?? 'N/A'}"),
        // Text("Available RAM: ${info['availableRAM'] ?? 'N/A'}"),
        Text("Available RAM: $_availableRam"),
        const SizedBox(height: 16),
        Text("💾 Storage", style: Theme.of(context).textTheme.titleMedium),
        Text("Internal Storage: ${info['internalStorage'] ?? 'N/A'}"),
        // Text("Available Storage: ${info['availableStorage'] ?? 'N/A'}"),
        Text("Available Storage: $_availableStorage"),
      ],
    );
  }

  Widget _buildBatteryTab() {
    if (_batteryInfo == null) {
      return const Center(child: CircularProgressIndicator());
    }

    final info = _batteryInfo!;
    return ListView(
      padding: const EdgeInsets.all(16),
      children: [
        Text("🔋 Battery Info",
            style: Theme.of(context).textTheme.headlineMedium),
        const SizedBox(height: 8),
        Text("Health: ${info['health'] ?? 'N/A'}"),
        Text("Level: ${info['level'] ?? 'N/A'}%"),
        Text("Power Source: ${info['powerSource'] ?? 'N/A'}"),
        Text("Status: ${info['status'] ?? 'N/A'}"),
        Text("Technology: ${info['technology'] ?? 'N/A'}"),
        Text("Temperature: ${info['temperature'] ?? 'N/A'} °C"),
        Text("Voltage: ${info['voltage'] ?? 'N/A'} mV"),
      ],
    );
  }

  Widget _buildSystemTab() {
    if (_systemInfo == null) {
      return const Center(child: CircularProgressIndicator());
    }

    final info = _systemInfo!;
    return ListView(
      padding: const EdgeInsets.all(16),
      children: [
        Text("🖥️ System Info",
            style: Theme.of(context).textTheme.headlineMedium),
        const SizedBox(height: 8),
        Text("Android Version: ${info['androidVersion'] ?? 'N/A'}"),
        Text("API Level: ${info['apiLevel'] ?? 'N/A'}"),
        Text("Security Patch Level: ${info['securityPatch'] ?? 'N/A'}"),
        Text("Bootloader: ${info['bootloader'] ?? 'N/A'}"),
        Text("Build ID: ${info['buildId'] ?? 'N/A'}"),
        Text("Java VM: ${info['javaVm'] ?? 'N/A'}"),
        Text("OpenGL ES: ${info['openGLES'] ?? 'N/A'}"),
        Text("Kernel Architecture: ${info['kernelArch'] ?? 'N/A'}"),
        Text("Kernel Version: ${info['kernelVersion'] ?? 'N/A'}"),
        Text("Root Access: ${info['rootAccess'] ?? 'N/A'}"),
        Text("Google Play Services: ${info['playServices'] ?? 'N/A'}"),
        Text("System Uptime: $_uptime"),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4, // Add more if you want more tabs
      child: Scaffold(
        appBar: AppBar(
          title: const Text('System Status Monitor'),
          bottom: const TabBar(
            // isScrollable: true,
            // tabAlignment: TabAlignment.start,
            tabs: [
              Tab(icon: Icon(Icons.memory), text: "SDC"),
              Tab(icon: Icon(Icons.graphic_eq), text: "DEVICE"),
              Tab(icon: Icon(Icons.graphic_eq), text: "SYSTEM"),
              Tab(icon: Icon(Icons.graphic_eq), text: "BATTERY"),
              // Tab(icon: Icon(Icons.graphic_eq), text: "THERMAL"),
              // Tab(icon: Icon(Icons.graphic_eq), text: "SENSORS"),
              // Tab(icon: Icon(Icons.graphic_eq), text: "ABOUT"),
              // Add more tabs here if needed
            ],
          ),
        ),
        body: TabBarView(
          children: [
            // These widgets need to be Stateless
            _buildSdcTab(),
            // _CpuTabContent(),
            _buildDeviceTab(),
            // _GpuTabContent(),
            _buildSystemTab(),
            _buildBatteryTab(),
            // _buildThermalTab(), // 🔥 New
            // _buildSensorsTab(), // 🧭 New
            // _buildAboutTab(), // 📖 New
          ],
        ),
      ),
    );
  }
}

/// Separate widgets to avoid rebuilding everything unnecessarily
// class _CpuTabContent extends StatelessWidget {
//   const _CpuTabContent();

//   @override
//   Widget build(BuildContext context) {
//     final state = context.findAncestorStateOfType<_SystemStatusPageState>();
//     return state?._buildCpuTab() ?? const Center(child: Text("Loading..."));
//   }
// }

// class _GpuTabContent extends StatelessWidget {
//   const _GpuTabContent();

//   @override
//   Widget build(BuildContext context) {
//     final state = context.findAncestorStateOfType<_SystemStatusPageState>();
//     return state?._buildGpuTab() ?? const Center(child: Text("Loading..."));
//   }
// }
1
likes
160
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to get system info like model, board, manufacturer, and screen size.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, plugin_platform_interface

More

Packages that depend on system_status_plugin

Packages that implement system_status_plugin