internal 0.1.15
internal: ^0.1.15 copied to clipboard
bravo merchant internal plugin
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:internal/internal.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';
late BuildContext _context;
final _internalPlugin = Internal();
@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 {
List list1 = [
{'msg': 'HAIDILAO Richmond', 'type': 'big'},
{'msg': '海底捞 - 列治文店', 'type': 'big'},
{'msg': '5890 No.3Rd Room 200 Richmond, BC. V6X 3P6', 'type': ''},
{'msg': '6043706665', 'type': ''},
{'msg': '', 'type': 'line'},
{'msg': 'Order#: O17104609576091149', 'type': ''},
{'msg': 'TXN: 17104609576091149', 'type': ''},
{'msg': 'Payment Method: QR Code', 'type': ''},
{'msg': 'Payment Code: V***9351', 'type': ''},
{'msg': 'Total: \$0.01', 'type': 'big'},
{
'msg': 'https://bravoupca/gift/24489d1eb106te10317fbb216b49bft5',
'type': 'qrcode'
},
];
platformVersion = "";
platformVersion =
await _internalPlugin.internalRequest(list1) ?? 'Unknown';
} on Exception {
platformVersion = 'Failed to get request reault.';
}
// 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;
});
}
getBody(context) {
_context = context;
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(children: [
Text('result: $_platformVersion\n'),
ElevatedButton(
onPressed: () {
int time = 1736289905000;
int yesterday = time - 86400000;
int nowtime = time;
int yesterdaytime = yesterday;
int lasttime = 10000;
nowtime += lasttime;
yesterdaytime += lasttime;
List data = [
{
'entrytime': '${nowtime + lasttime * 1}',
'amount': 0,
'tip': 0
},
{
'entrytime': '${yesterdaytime + lasttime * 1}',
'amount': 1,
'tip': 0
},
{
'entrytime': '${nowtime + lasttime * 2}',
'amount': 2,
'tip': 50
},
{
'entrytime': '${yesterdaytime + lasttime * 2}',
'amount': 3,
'tip': 108
},
{
'entrytime': '${nowtime + lasttime * 3}',
'amount': 4,
'tip': 1
},
{
'entrytime': '${yesterdaytime + lasttime * 3}',
'amount': 5,
'tip': 380
},
{
'entrytime': '${nowtime + lasttime * 4}',
'amount': 6,
'tip': 480
},
{
'entrytime': '${yesterdaytime + lasttime * 4}',
'amount': 7,
'tip': 108
},
{
'entrytime': '${nowtime + lasttime * 5}',
'amount': 8,
'tip': 109
},
{
'entrytime': '${nowtime + lasttime * 6}',
'amount': 9,
'tip': 1180
},
{
'entrytime': '${yesterdaytime + lasttime * 5}',
'amount': 10,
'tip': 1280
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 11,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 12,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 13,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 14,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 15,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 16,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 17,
'tip': 1380
},
{
'entrytime': '${nowtime + lasttime * 7}',
'amount': 18,
'tip': 1380
},
];
for(int i = 0; i <2000;i++){
data.add({
'entrytime': '${yesterdaytime + lasttime * 5 + i}',
'amount': 12 + i,
'tip': 1380 + i
});
}
List list1 = [
{
'type': 'table',
'name': 'historytransaction',
'title': 'Transaction',
'where':
'entrytime=@today order by entrytime desc', //'2024-03-13'
'orderby': 'date desc',
'orderasc': 'desc',
'columns': [
{
"id": "entrytime",
"dbid": "entrytime",
"type": "datetime",
"label": "Date",
"defaultValue": "",
"required": false,
"minLength": 0,
"length": 255,
"hash": false,
"unit": "character",
"prefixIcon": null,
"inputType": "datetime",
"fontSize": null,
"letterSpacing": 0.0,
"isPrimary": false,
"isKeyword": false,
"droplist": "",
"uniqueKey": "",
"isUnique": false,
"colType": "java.lang.Long",
"isFile": false,
"seq": 10,
"canshow": true,
"fromsource": "",
"isFrozen": false,
"addNewCheck": false,
"isWholePage": false,
"after": "",
"showrange": "table",
"Advanced search": true,
},
{
"id": "amount",
"dbid": "amount",
"type": "money",
"label": "Amount",
"defaultValue": "",
"required": false,
"minLength": 0,
"length": 80,
"hash": false,
"unit": "character",
"prefixIcon": null,
"inputType": "money",
"fontSize": null,
"letterSpacing": 0.0,
"isPrimary": false,
"isKeyword": false,
"droplist": "",
"uniqueKey": "",
"isUnique": false,
"colType": "java.lang.Long",
"isFile": false,
"seq": 20,
"canshow": true,
"fromsource": "",
"isFrozen": false,
"addNewCheck": false,
"isWholePage": false,
"after": "",
"showrange": "",
"sumtype": "sum",
},
{
"id": "tip",
"dbid": "tip",
"type": "money",
"label": "Tip",
"defaultValue": "",
"required": false,
"minLength": 0,
"length": 80,
"hash": false,
"unit": "character",
"prefixIcon": null,
"inputType": "money",
"fontSize": null,
"letterSpacing": 0.0,
"isPrimary": false,
"isKeyword": false,
"droplist": "",
"uniqueKey": "",
"isUnique": false,
"colType": "java.lang.Long",
"isFile": false,
"seq": 30,
"canshow": true,
"fromsource": "",
"isFrozen": false,
"addNewCheck": false,
"isWholePage": false,
"after": "",
"showrange": "",
"sumtype": "sum",
},
],
'data': data,
'context': _context,
},
];
_internalPlugin.internalRequest(list1);
},
child: const Text('table Example')),
ElevatedButton(
onPressed: () async {
List list1 = [
{'type': 'getSerial(SUNMI)'}
];
dynamic serial =
await _internalPlugin.internalRequest(list1) ?? 'Unknown';
setState(() {
_platformVersion = serial;
});
},
child: const Text('getSerial')),
ElevatedButton(
onPressed: () {
initPlatformState();
},
child: const Text('print receipt')),
ElevatedButton(
onPressed: () async {
List list1 = [
{'type': 'getScanCode()'}
];
dynamic scancode =
await _internalPlugin.internalRequest(list1) ?? 'Unknown';
setState(() {
_platformVersion = scancode;
});
},
child: const Text('getScanCode')),
]),
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(builder: (context) => getBody(context)),
);
}
}