performance_class 1.0.0 copy "performance_class: ^1.0.0" to clipboard
performance_class: ^1.0.0 copied to clipboard

discontinuedreplaced by: anpec
PlatformAndroid

A Flutter FFI plugin for Android device performance classification. Analyzes device hardware and software capabilities to classify Android devices into performance categories (Low, Average, High).

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:performance_class/performance_class.dart' as performance_class;
import 'package:performance_class/performance_class_bindings_generated.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  late Map<String, dynamic> deviceInfo;
  late String performanceClass;
  late int cpuFreq;

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

  void _loadDeviceInfo() {
    final classifier = performance_class.PerformanceClassifier.instance;

    // Get detailed device information
    deviceInfo = classifier.getDetailedDeviceInfo();

    // Get performance class string
    final result = classifier.getPerformanceClass();
    performanceClass = classifier.getPerformanceClassString(
      PerformanceClass.fromValue(result.performance_class),
    );

    // Get CPU frequency
    cpuFreq = classifier.readAverageMaxCpuFreq(deviceInfo['cpuCount']);
  }

  @override
  Widget build(BuildContext context) {
    const textStyle = TextStyle(fontSize: 16);
    const titleStyle = TextStyle(fontSize: 18, fontWeight: FontWeight.bold);
    const spacerSmall = SizedBox(height: 10);
    const spacerMedium = SizedBox(height: 20);

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Performance Class Plugin'),
          backgroundColor: Colors.blue,
          foregroundColor: Colors.white,
        ),
        body: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(16),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                const Text(
                  'Android Device Performance Classification',
                  style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
                ),
                spacerMedium,

                // Android-only warning
                Container(
                  padding: const EdgeInsets.all(16),
                  decoration: BoxDecoration(
                    color: Colors.orange.shade50,
                    borderRadius: BorderRadius.circular(8),
                    border: Border.all(color: Colors.orange.shade200),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Row(
                        children: [
                          Icon(Icons.warning, color: Colors.orange.shade700),
                          const SizedBox(width: 8),
                          const Text(
                            'Android Only',
                            style: TextStyle(
                              fontSize: 18,
                              fontWeight: FontWeight.bold,
                              color: Colors.orange,
                            ),
                          ),
                        ],
                      ),
                      spacerSmall,
                      const Text(
                        'This plugin is designed specifically for Android devices only. '
                        'While it may run on other platforms, it will not provide accurate '
                        'performance classification.',
                        style: TextStyle(fontSize: 14),
                      ),
                    ],
                  ),
                ),
                spacerMedium,

                const Text(
                  'This plugin analyzes your Android device\'s hardware and software capabilities '
                  'to classify it into a performance category. The classification is based on factors '
                  'like CPU cores, memory, Android version, and media performance class.',
                  style: textStyle,
                ),
                spacerMedium,

                // Performance Class Section
                Container(
                  padding: const EdgeInsets.all(16),
                  decoration: BoxDecoration(
                    color: Colors.blue.shade50,
                    borderRadius: BorderRadius.circular(8),
                    border: Border.all(color: Colors.blue.shade200),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text(
                        'Performance Classification',
                        style: titleStyle,
                      ),
                      spacerSmall,
                      Text('Class: $performanceClass', style: textStyle),
                      Text(
                        'Raw Value: ${deviceInfo['performanceClassRaw']}',
                        style: textStyle,
                      ),
                      Text(
                        'Is High-End: ${deviceInfo['isHighEnd']}',
                        style: textStyle,
                      ),
                      Text(
                        'Is Low-End: ${deviceInfo['isLowEnd']}',
                        style: textStyle,
                      ),
                    ],
                  ),
                ),
                spacerMedium,

                // Device Information Section
                Container(
                  padding: const EdgeInsets.all(16),
                  decoration: BoxDecoration(
                    color: Colors.green.shade50,
                    borderRadius: BorderRadius.circular(8),
                    border: Border.all(color: Colors.green.shade200),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text('Device Information', style: titleStyle),
                      spacerSmall,
                      Text(
                        'Android Version: ${deviceInfo['androidVersion']}',
                        style: textStyle,
                      ),
                      Text(
                        'CPU Cores: ${deviceInfo['cpuCount']}',
                        style: textStyle,
                      ),
                      Text(
                        'Memory: ${deviceInfo['memoryClassMb']} MB',
                        style: textStyle,
                      ),
                      Text(
                        'Max CPU Frequency: ${deviceInfo['maxCpuFreqMhz']} MHz',
                        style: textStyle,
                      ),
                      Text(
                        'Media Performance Class: ${deviceInfo['mediaPerformanceClass']}',
                        style: textStyle,
                      ),
                      Text(
                        'Read CPU Frequency: ${cpuFreq == -1 ? 'Unable to read' : '$cpuFreq MHz'}',
                        style: textStyle,
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
6
downloads

Publisher

verified publisheraryak.dev

Weekly Downloads

A Flutter FFI plugin for Android device performance classification. Analyzes device hardware and software capabilities to classify Android devices into performance categories (Low, Average, High).

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on performance_class

Packages that implement performance_class