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

梁典典扫码监听数据插件

m_phone_scan #

扫描监听插件

Getting Started #



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

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

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

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: ListView(
          children: [
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.openScanner();
            }, child: const Text('开启扫描')),
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.closeScanner();
            }, child: const Text('关闭扫描')),
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.startDecode();
            }, child: const Text('启动扫描(扫描头出光)')),
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.startDecode();
            }, child: const Text('取消扫描')),
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.isScannerOpen();
            }, child: const Text('扫描是否开启')),
            ElevatedButton(onPressed: (){
              MPhoneScanPlatform.instance.setPlaySound(true);
            }, child: const Text('设置声音')),
            ElevatedButton(onPressed: (){
              MethodChannelMPhoneScan().listenScanData((Map<String,dynamic> data){
                debugPrint("扫描到数据:$data");
              });
            }, child: const Text('扫描数据监听')),
            ElevatedButton(onPressed: (){
              MethodChannelMPhoneScan().listenScanData((Map<String,dynamic> data){
                debugPrint("扫描到数据:$data");
              });
            }, child: const Text('关闭扫描数据监听')),
          ],
        ),
      ),
    );
  }
}


0
likes
105
pub points
0%
popularity

Publisher

unverified uploader

梁典典扫码监听数据插件

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on m_phone_scan