pda_scanner 0.1.5 copy "pda_scanner: ^0.1.5" to clipboard
pda_scanner: ^0.1.5 copied to clipboard

outdated

This is a scanning plug-in for PDA(Dong ji Xiao ma ge) to Listen for scanned events and get results.

example/lib/main.dart

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

import 'package:flutter/services.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  static const scannerPlugin =
      const EventChannel('com.shinow.pda_scanner/plugin');

  StreamSubscription _subscription;

  var _code;

  @override
  void initState() {
    super.initState();
    if (_subscription == null) {
      _subscription = scannerPlugin
          .receiveBroadcastStream()
          .listen(_onEvent, onError: _onError);
    }
  }

  @override
  void dispose() {
    super.dispose();
    if (_subscription != null) {
      _subscription.cancel();
    }
  }

  void _onEvent(Object event) {
    setState(() {
      _code = event;
      print("ChannelPage: $event");
    });
  }

  void _onError(Object error) {
    setState(() {
      _code = "扫描异常";
      print(error);
    });
  }

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

Publisher

unverified uploader

This is a scanning plug-in for PDA(Dong ji Xiao ma ge) to Listen for scanned events and get results.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on pda_scanner