ehsure_pda_plugin 1.0.0 ehsure_pda_plugin: ^1.0.0 copied to clipboard
An Ehsure PDA Flutter plugin.
import 'package:ehsure_pda_plugin/ehsure_pda_plugin.dart';
import 'package:flutter/material.dart';
import 'dart:convert' as convert;
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _erCodeValue = 'Unknown';
@override
void initState() {
super.initState();
_register();
EhsurePdaPlugin.EHSURE_SCANNER_CHANNEL.setMessageHandler(
(String message) => Future<String>(() {
setState(() {
_erCodeValue = message;
});
return message;
}),
);
}
void _register() async {
var pdaInfo = { EhsurePdaPlugin.ACTION_KEY: EhsurePdaPlugin.ACTION_VALUE,
EhsurePdaPlugin.EXTRA_KEY: EhsurePdaPlugin.EXTRA_VALUE};
String pdaInfoJsonStr = convert.jsonEncode(pdaInfo);
await EhsurePdaPlugin.EHSURE_SCANNER_CHANNEL.send(pdaInfoJsonStr);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('ErCode is: $_erCodeValue\n'),
),
),
);
}
}