device_all_ggez 1.0.1 copy "device_all_ggez: ^1.0.1" to clipboard
device_all_ggez: ^1.0.1 copied to clipboard

PlatformAndroid

A very easily accessible and easy to use android exclusive device metric plugin.

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isLoading = true;
  String? _error;

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

  Future<void> _refreshMetrics() async {
    setState(() {
      _isLoading = true;
      _error = null;
    });

    try {
      // πŸ”„ Refreshes metrics from native Android
      await DeviceAllGgez.refresh();

      setState(() {
        _isLoading = false;
      });
    } catch (e) {
      setState(() {
        _error = e.toString();
        _isLoading = false;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: Colors.teal,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('DeviceAllGgez Demo'),
          actions: [
            IconButton(
              icon: const Icon(Icons.refresh),
              tooltip: 'DeviceAllGgez.refresh()',
              onPressed: _refreshMetrics,
            ),
          ],
        ),
        floatingActionButton: FloatingActionButton.extended(
          onPressed: _refreshMetrics,
          icon: const Icon(Icons.refresh),
          label: const Text('DeviceAllGgez.refresh()'),
        ),
        body: _isLoading
            ? const Center(child: CircularProgressIndicator())
            : _error != null
                ? Center(child: Text('Error: $_error'))
                : _buildMetricsView(),
      ),
    );
  }

  Widget _buildMetricsView() {
    return ListView(
      padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 80.0),
      children: [
        // Property 1: DeviceAllGgez.build -> Property 2: sub-properties
        _buildCategoryCard('πŸ”₯ Build Metrics (DeviceAllGgez.build)', {
          'Brand / Model': '${DeviceAllGgez.build.brand} ${DeviceAllGgez.build.model}',
          'Manufacturer': DeviceAllGgez.build.manufacturer,
          'Hardware / Board': '${DeviceAllGgez.build.hardware} / ${DeviceAllGgez.build.board}',
          'Device / Product': '${DeviceAllGgez.build.device} / ${DeviceAllGgez.build.product}',
          'Bootloader': DeviceAllGgez.build.bootloader,
          'Display ID': DeviceAllGgez.build.display,
          'Fingerprint': DeviceAllGgez.build.fingerprint,
          'Supported ABIs': DeviceAllGgez.build.supportedAbis.join(', '),
          'SoC Manufacturer': DeviceAllGgez.build.socManufacturer ?? 'N/A (< API 31)',
          'SoC Model': DeviceAllGgez.build.socModel ?? 'N/A (< API 31)',
        }),

        // Property 1: DeviceAllGgez.osVersion -> Property 2: sub-properties
        _buildCategoryCard('πŸ“± OS Version Metrics (DeviceAllGgez.osVersion)', {
          'Android Version': DeviceAllGgez.osVersion.release,
          'SDK Int': '${DeviceAllGgez.osVersion.sdkInt}',
          'Codename': DeviceAllGgez.osVersion.codename,
          'Security Patch': DeviceAllGgez.osVersion.securityPatch ?? 'N/A',
          'Incremental': DeviceAllGgez.osVersion.incremental,
          'Base OS': DeviceAllGgez.osVersion.baseOs ?? 'N/A',
        }),

        // Property 1: DeviceAllGgez.clock -> Property 2: sub-properties
        _buildCategoryCard('⏰ Clock Metrics (DeviceAllGgez.clock)', {
          'Current Epoch Ms': '${DeviceAllGgez.clock.currentTimeMillis}',
          'Uptime Ms': '${DeviceAllGgez.clock.uptimeMillis}',
          'Elapsed Realtime Ms': '${DeviceAllGgez.clock.elapsedRealtimeMillis}',
          'Calculated Boot Time':
              DeviceAllGgez.clock.bootTime.toLocal().toString(),
          'Time Zone':
              '${DeviceAllGgez.clock.timeZoneId} (${DeviceAllGgez.clock.timeZoneDisplayName})',
        }),

        // Property 1: DeviceAllGgez.system -> Property 2: sub-properties
        _buildCategoryCard('πŸ’» System Metrics (DeviceAllGgez.system)', {
          'Processor Count (Cores)': '${DeviceAllGgez.system.processorCount}',
          'Is Low RAM Device': '${DeviceAllGgez.system.isLowRamDevice}',
          'Total RAM': '${DeviceAllGgez.system.ramTotalGB.toStringAsFixed(2)} GB',
          'Available RAM': '${DeviceAllGgez.system.ramAvailGB.toStringAsFixed(2)} GB',
          'Internal Storage Total':
              '${DeviceAllGgez.system.storageTotalGB.toStringAsFixed(2)} GB',
          'Internal Storage Usable':
              '${DeviceAllGgez.system.storageUsableGB.toStringAsFixed(2)} GB',
        }),

        // Property 1: DeviceAllGgez.hardware -> Property 2: sub-properties
        _buildCategoryCard('🌐 Hardware Metrics (DeviceAllGgez.hardware)', {
          'OpenGL ES Version': DeviceAllGgez.hardware.openGlVersion ?? 'Unknown',
          'Thermal Status': DeviceAllGgez.hardware.thermalStatus,
          'Locale': DeviceAllGgez.hardware.locale,
          'Language / Country':
              '${DeviceAllGgez.hardware.language} / ${DeviceAllGgez.hardware.country}',
        }),
      ],
    );
  }

  Widget _buildCategoryCard(String title, Map<String, String> items) {
    return Card(
      margin: const EdgeInsets.only(bottom: 16.0),
      elevation: 2,
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              title,
              style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
            ),
            const Divider(),
            for (final entry in items.entries)
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 3.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(entry.key,
                        style: TextStyle(color: Colors.grey.shade700)),
                    const SizedBox(width: 8),
                    Expanded(
                      child: Text(
                        entry.value,
                        textAlign: TextAlign.end,
                        style: const TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ),
                  ],
                ),
              ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
36
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A very easily accessible and easy to use android exclusive device metric plugin.

Homepage

Topics

#android #device-info #system-info #hardware #metrics

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on device_all_ggez

Packages that implement device_all_ggez