sunmi_uhf 0.0.2 copy "sunmi_uhf: ^0.0.2" to clipboard
sunmi_uhf: ^0.0.2 copied to clipboard

PlatformAndroid
outdated

A new Flutter project.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String? _result = 'Unknown';

  @override
  void initState() {
    super.initState();
    SunmiUhf.init();
    SunmiUhf.onUhfScanned().listen((event) {
      if(event != null) {
        _result = event;
        setState(() {});
      }

    });
  }

  @override
  void dispose() {
    SunmiUhf.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Sunmi uhf'),
        ),
        body: Center(
          child: Text('Scan result: $_result\n'),
        ),
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.scanner),
          onPressed: (){
            SunmiUhf.scan();
          },
        ),
      ),
    );
  }
}
0
likes
135
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter project.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on sunmi_uhf

Packages that implement sunmi_uhf