hardwareinfo 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

hardwareinfo #

A plugin to show the hardware informations of a device Currently works only on android. Supports IOS shortly.

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:hardwareinfo/hardwareinfo.dart';

void main() => runApp(mains());
class mains extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyApp(),
    );
  }
}


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

class _MyAppState extends State<MyApp> {
  String _platformVersion="unknown",_maxcpuFreq="unknown",_mincpuFreq="unknown",_currcpuFreq="unknown",_model,_company,_batterylevel;
  String _totalinternalmemory,_usedinternalmemory,_freeinternalmemory,_totalexternalmemory,_usedexternalmemory,_freeexternalmemory;
  String _totalRam,_cputemp;
  int _noOfCores;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }
  Future<void> initPlatformState() async {
    String platformVersion,maxfreq,minfreq,currfreq,model,company,batterylevel,cputemp;
    String usedinternal,freeinternal,totalinternal;
    String usedexternal,freeexternal,totalexternal;
    String totalram,availRam;
    int cores;
    try {
      platformVersion = await Hardwareinfo.platformVersion;
      maxfreq = await Hardwareinfo.cpuMaxFreq;
      minfreq = await Hardwareinfo.cpuMinFreq;
      currfreq = await Hardwareinfo.cpuCurrFreq;
      cores = await Hardwareinfo.cpuCore;
      company = await Hardwareinfo.company;
      model = await Hardwareinfo.model;
      batterylevel =null;
      totalinternal = await Hardwareinfo.totalInternalMemory;
      freeinternal = await Hardwareinfo.freeInternalMemory;
      usedinternal = await Hardwareinfo.usedInternalMemory;
      totalexternal = await Hardwareinfo.totalExternalMemory;
      freeexternal = await Hardwareinfo.freeExternalMemory;
      usedexternal = await Hardwareinfo.usedExternalMemory;
      totalram = await Hardwareinfo.totalRAM;
      cputemp = await Hardwareinfo.cpuTemp;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
      _maxcpuFreq = maxfreq;
      _mincpuFreq = minfreq;
      _noOfCores = cores;
      _currcpuFreq = currfreq;
      _model = model;
      _company = company;
      _batterylevel = batterylevel;
      _usedinternalmemory = usedinternal;
      _freeinternalmemory = freeinternal;
      _totalinternalmemory = totalinternal;
      _totalexternalmemory = totalexternal;
      _freeexternalmemory = freeexternal;
      _usedexternalmemory = usedexternal;
      _totalRam = totalram;
      _cputemp = cputemp;

    });
  }

  @override
  Widget build(BuildContext context) {
    final double width = MediaQuery.of(context).size.width;
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('System info app'),
        ),
        body: SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.only(left: 20,top:  10),
            child: Container(
              width: width-20,
              child:  Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  Card(
                    child:Padding(
                      padding: EdgeInsets.all(10),
                      child: Container(
                      width: width-20,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text('CPU\n',style: TextStyle(fontSize: 23),),
                          Text('Maximum frequency (in Hz): ${_maxcpuFreq }'),
                          Text('Minimum frequency (in Hz): ${_mincpuFreq}'),
                          Text('Current frequency (in Hz): ${_currcpuFreq}'),
                          Text('No of Cores: ${_noOfCores}\n'),
                          Text('CPU Temp: ${_cputemp}\n'),
                        ],
                      ),
                    ),
                    )
                  ),
                  Card(
                      child:Padding(
                        padding: EdgeInsets.all(10),
                        child: Container(
                          width: width-20,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Text('Device Info \n',style: TextStyle(fontSize: 23),),
                              Text('Android Version: $_platformVersion \n'),
                              Text('Menufacturer: $_company\n'),
                              Text('Model: $_model\n'),
                            ],
                          ),
                        ),
                      )
                  ),
                  Card(
                      child:Padding(
                        padding: EdgeInsets.all(10),
                        child: Container(
                          width: width-20,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Text('Memory Info \n',style: TextStyle(fontSize: 23),),
                              Text('Total Internal Memory: $_totalinternalmemory \n'),
                              Text('Available Internal Memory: $_freeinternalmemory\n'),
                              Text('Used Internal Memory: $_usedinternalmemory\n'),
                              Text('Total External Memory: $_totalexternalmemory \n'),
                              Text('Available External Memory: $_freeexternalmemory\n'),
                              Text('Used External Memory: $_usedexternalmemory\n'),
                            ],
                          ),
                        ),
                      )
                  ),
                  Card(
                      child:Padding(
                        padding: EdgeInsets.all(10),
                        child: Container(
                          width: width-20,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Text('RAM Info \n',style: TextStyle(fontSize: 23),),
                              Text('Total RAM: $_totalRam \n'),
                            ],
                          ),
                        ),
                      )
                  ),
                ],
              ),
            ),
          )
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.refresh),
          onPressed: (){
            initPlatformState();
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  hardwareinfo: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:hardwareinfo/hardwareinfo.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:hardwareinfo/hardwareinfo.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:hardwareinfo/hardwareinfo.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:hardwareinfo/hardwareinfo.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:hardwareinfo/hardwareinfo.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [hardwareinfo] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

19 out of 19 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/hardware.dart. (-0.50 points)

Analysis of lib/hardware.dart reported 1 hint:

line 58 col 18: Name non-constant identifiers using lowerCamelCase.

Format lib/hardwareinfo.dart.

Run flutter format to format lib/hardwareinfo.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test