devicetemperature 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

device_temperature #

device_temperature is a flutter plugin that can provide you the current temperature of an android device.

- Note: This plugin can work only in Android as of now!

Usage #

import 'package:devicetemperature/devicetemperature.dart';

double temperature = await Devicetemperature.DeviceTemperature;

Available Methods #

  • getDeviceTemperature

Contributing #

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

License #

MIT

0.0.1 #

  • Now you can get current device temperature for android devices.

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> {
  String _temp = "";

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initDeviceTemperature() async {
    double temp;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      temp = await Devicetemperature.DeviceTemperature;
    } catch(e) {
      temp = 0.0;
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _temp = "Current Device Temperature is " + temp.toString() + " degree Celsius";
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Device Temperature'),
        ),
        body: Center(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  child: Text('$_temp'),
                  margin: EdgeInsets.all(15),
                ),
                RaisedButton(
                  child: Text("Get Device Temperature"),
                  onPressed: initDeviceTemperature,
                )
              ],
            ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  devicetemperature: ^0.0.1

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:devicetemperature/devicetemperature.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
81
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:devicetemperature/devicetemperature.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:devicetemperature/devicetemperature.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:devicetemperature/devicetemperature.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:devicetemperature/devicetemperature.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • devicetemperature that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 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/devicetemperature.dart. (-2.96 points)

Analysis of lib/devicetemperature.dart reported 6 hints, including:

line 2 col 8: Duplicate import.

line 3 col 8: Duplicate import.

line 4 col 8: Duplicate import.

line 5 col 8: Duplicate import.

line 6 col 8: Unused import: 'dart:ffi'.

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.

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

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