cpu_reader 3.0.0 copy "cpu_reader: ^3.0.0" to clipboard
cpu_reader: ^3.0.0 copied to clipboard

PlatformAndroid

Flutter CPU reader plugin providing detailed information about the device's CPU data (freq, temp, cores, etc). Android only!

example/lib/main.dart

import 'package:cpu_reader/cpu_reader.dart';
import 'package:cpu_reader/cpuinfo.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('CPU Reader'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: [
              FutureBuilder<CpuInfo>(
                  future: CpuReader.cpuInfo,
                  builder: (context, AsyncSnapshot<CpuInfo> snapshot) =>
                      snapshot.hasData
                          ? Text(
                              'Number of cores: ${snapshot.data.numberOfCores}')
                          : Text('No data!')),
              StreamBuilder<CpuInfo>(
                  stream: CpuReader.cpuStream(1000),
                  builder: (_, AsyncSnapshot<CpuInfo> snapshot) {
                    if (snapshot.hasData) {
                      return Column(
                        children: buildFreqList(snapshot),
                      );
                    }
                    return Text('No data!');
                  }),
            ],
          ),
        ),
      ),
    );
  }

  List<Row> buildFreqList(AsyncSnapshot<CpuInfo> snapshot) {
    return snapshot.data.currentFrequencies.entries
        .map((entry) => Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [Text('CPU ${entry.key} '), Text('${entry.value}')]))
        .toList();
  }
}
15
likes
150
points
191
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter CPU reader plugin providing detailed information about the device's CPU data (freq, temp, cores, etc). Android only!

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on cpu_reader