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

钱箱插件,打开钱箱,支持联迪设备.

example/lib/main.dart

import 'dart:ffi';
import 'dart:math';

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

import 'package:flutter/services.dart';
import 'package:cashbox/cashbox.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final _cashboxPlugin = Cashbox();

  open() async {
    var ss = await _cashboxPlugin.openBox();
    print(ss);
  }

  readM1Card() {
    _cashboxPlugin.startActivityForResult({
      "action": "com.icbc.smartpos.transservice.devices",
      "cmd": "MIFARE1_CARD",
      "ctrlData": {"APP_NAME": "管理帮手", "BANKPAY_VER": "1020700L"},
      "transData": {
        "MODE": "1L",
        "BLOCK_NO": "0L",
        "TIME_OUT": "20L",
        "KEY_A": Uint8List.fromList([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]),
        "KEY_B": Uint8List.fromList([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
      }
    }).then(han);
  }

  readCard() {
    _cashboxPlugin.startActivityForResult({
      "action": "com.icbc.smartpos.transservice.devices",
      "cmd": "READ_MAGCARD",
      "ctrlData": {"APP_NAME": "管理帮手", "BANKPAY_VER": "1020700L"},
      "transData": {"TIME_OUT": "10L"}
    }).then(han);
  }

  startScan() {
    _cashboxPlugin.startActivityForResult({
      "action": "com.icbc.smartpos.transservice.devices",
      "cmd": "START_SCAN",
      "ctrlData": {"APP_NAME": "管理帮手", "BANKPAY_VER": "1020700L"},
      "transData": {"CAMERA_ID": "1L"}
    }).then(han);
  }

  han(String? sss) {
    print(sss);
  }

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion = await _cashboxPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('Running on: $_platformVersion\n'),
              FloatingActionButton(onPressed: open, child: const Text("打开")),
              FloatingActionButton(
                  onPressed: startScan, child: const Text("A90扫码")),
              FloatingActionButton(
                  onPressed: readCard, child: const Text("A90读磁卡")),
              FloatingActionButton(
                  onPressed: readM1Card, child: const Text("A90读M1卡"))
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
145
downloads

Publisher

unverified uploader

Weekly Downloads

钱箱插件,打开钱箱,支持联迪设备.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on cashbox