performance_class 1.1.0
performance_class: ^1.1.0 copied to clipboard
A Flutter FFI plugin for Android device performance classification.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:performance_class/performance_class.dart' as performance_class;
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 performance_class.PerformanceClass 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 enum directly
performanceClass = classifier.getPerformanceClass();
// 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.name}', style: textStyle),
Text(
'Display Name: ${deviceInfo['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,
),
],
),
),
],
),
),
),
),
);
}
}