imin_electronic_scale 0.0.4 copy "imin_electronic_scale: ^0.0.4" to clipboard
imin_electronic_scale: ^0.0.4 copied to clipboard

PlatformAndroid

A new flutter plugin project.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:imin_electronic_scale/imin_electronic_scale.dart';

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

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

class _MyAppState extends State<MyApp> {
  String? _weight;
  String? _weightStatus;
  IminElectronicScale _scale = IminElectronicScale();

  @override
  void initState() {
    super.initState();
    _scale.initElectronic();
    _scale.setWeightInfoCallback((weight, weightStatus) {
      _weight = weight;
      _weightStatus = weightStatus;
      if (mounted) setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('IminElectronicScale'),
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Expanded(
                child: Center(
              child: Text(
                'weight: $_weight weightStatus: $_weightStatus',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.headline5,
              ),
            )),
            ElevatedButton(
                onPressed: () {
                  _scale.turnZero();
                },
                child: Text('Turn Zero')),
            ElevatedButton(
                onPressed: () {
                  _scale.manualPeel(100);
                },
                child: Text('Manual Peel 100g')),
            ElevatedButton(
                onPressed: () {
                  _scale.removePeel();
                },
                child: Text('Remove Peel')),
            ElevatedButton(
                onPressed: () {
                  _scale.closeElectronic();
                },
                child: Text('Close Electronic')),
            SizedBox(
              height: 20,
            ),
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _scale.dispose();
  }
}
0
likes
135
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A new flutter plugin project.

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on imin_electronic_scale

Packages that implement imin_electronic_scale