baro_service 0.0.1 copy "baro_service: ^0.0.1" to clipboard
baro_service: ^0.0.1 copied to clipboard

Barometer sensor listener plugin.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  double? _pressure = 0.0;
  StreamSubscription? _pressureListener;

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

    _pressureListener = baroSersor.absolutePressure.listen((event) {
      setState(() {
        _pressure = event.pressure;
      });
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Pressure (pHa): $_pressure\n'),
        ),
      ),
    );
  }
}
0
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Barometer sensor listener plugin.

Homepage

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on baro_service