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

outdated

Flutter package for Mobiocean POS machine to access printer, NFC

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:mo_a5_plugin/mo_a5_plugin.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 _platformVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String responseString = "";
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      String content = "     *NEPAL TOURISM*     \n" +
          "Date : 04/05/2022        \n" +
          "Date  :        04/05/2022\n" +
          "Time  :          05:32 PM\n" +
          "Bus No:       UP-14AZ1512\n" +
          "  Delhi   to   Ghazibad  \n" +
          "Adult (2 X 100) =  200.00\n" +
          "Child (1 X 50)  =   50.00\n" +
          "     Total    250.00     \n" +
          "      *SHUB YATRA*       ";

      //To print the string
      responseString = await MoA5Plugin.printContent(content: content) ?? 'Unknown platform version';
      // 0 - Success, -1 - Low power, -2 - No paper, -3 - Printer over heat, -4 - Unknown error

      //First start Reader
      responseString =
          await MoA5Plugin.startNfc() ?? 'Unknown platform version';
      // 0 - open Success, -1 - open error

      //To Stop reader
      responseString =
          await MoA5Plugin.closeNfc() ?? 'Unknown platform version';
      // 0 - close Success, -1 - close error

      //To read card and get card no after successfull open
      responseString =
          await MoA5Plugin.startReading() ?? 'Unknown platform version';
      // -1 - time out error, -2 - unknown card, -3 - Exception else json data with card details

      //To halt any on going operation
      responseString =
          await MoA5Plugin.haltOperation() ?? 'Unknown platform version';
      // 0 - halt Success, -1 - halt error

      //To auth card via password after successfull read
      var blockNo = 2;
      var authKey = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; //byte array keys
      responseString =
          await MoA5Plugin.authBlock(blockNo: blockNo, authKey: authKey) ?? 'Unknown platform version';
      // -1 - time out error, -2 - unknown card, -3 - Exception {else} json data with card details

      //To read block after successfull authentication
      blockNo = 2;
      responseString =
          await MoA5Plugin.readBlock(blockNo: blockNo) ?? 'Unknown platform version';
      // null - error {else} value in the block

      //To write block after successfull authentication
      blockNo = 2;
      var value = "Hello";
      responseString =
          await MoA5Plugin.writeBlock(blockNo: blockNo, conent: value) ?? 'Unknown platform version';
      // 0 - success, -1 - error
    } on PlatformException {
      responseString = '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 = responseString;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}
0
likes
0
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package for Mobiocean POS machine to access printer, NFC

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on mo_a5_plugin

Packages that implement mo_a5_plugin