healthrian_ble_support_for_wearecg12 1.31.1 copy "healthrian_ble_support_for_wearecg12: ^1.31.1" to clipboard
healthrian_ble_support_for_wearecg12: ^1.31.1 copied to clipboard

unlisted

Healthrian BLE support library for WearECG12

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:healthrian_ble_support_for_wearecg12/healthrian_ble_support_for_wearecg12.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: const MyHomePage());
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _manager = BLEManager();
  late final _ble = _manager.ble;
  late final _streams = _ble.streams;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Observer(
                builder: (context) => StreamBuilder(
                  stream: _streams.ble.connection,
                  builder: (context, snapshot) =>
                      Text(snapshot.data.toString()),
                ),
              ),
              Observer(
                builder: (context) => StreamBuilder(
                  stream: _streams.ble.battery,
                  builder: (context, snapshot) =>
                      Text(snapshot.data.toString()),
                ),
              ),
              Observer(
                builder: (context) => StreamBuilder(
                  stream: _streams.ecg.preload.raw,
                  builder: (context, snapshot) =>
                      Text(snapshot.data.toString()),
                ),
              ),
              Observer(
                builder: (context) => StreamBuilder(
                  stream: _streams.ble.tap,
                  builder: (context, snapshot) =>
                      Text(snapshot.data.toString()),
                ),
              ),
              Observer(
                builder: (context) => StreamBuilder(
                  stream: _streams.ecg.preload.raw,
                  builder: (context, snapshot) =>
                      Text(snapshot.data.toString()),
                ),
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          FloatingActionButton(
            onPressed: _ble.connectAndRegister,
            child: const Icon(Icons.bluetooth),
          ),
          FloatingActionButton(
            onPressed: _manager.ecg?.start,
            child: const Icon(Icons.play_arrow),
          ),
          FloatingActionButton(
            onPressed: _manager.ecg?.stop,
            child: const Icon(Icons.stop),
          ),
          FloatingActionButton(
            onPressed: _ble.disconnectDevice,
            child: const Icon(Icons.bluetooth_disabled),
          ),
        ],
      ),
    );
  }
}
1
likes
110
pub points
5%
popularity

Publisher

unverified uploader

Healthrian BLE support library for WearECG12

Homepage
Repository

Documentation

API reference

License

MIT (license)

Dependencies

healthrian_ble_interface

More

Packages that depend on healthrian_ble_support_for_wearecg12