b4u_pos_sdk 0.0.2 b4u_pos_sdk: ^0.0.2 copied to clipboard
B4U POS SDk for Android
import 'package:b4u_pos_sdk/model/qr_response.dart';
import 'package:flutter/material.dart';
import 'package:b4u_pos_sdk/b4u_pos_sdk.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? amount;
QrResponse? qrResponse;
@override
void initState() {
super.initState();
}
getQRFromPlugin() async {
try {
var response = await B4uPosSdk.getQR(double.parse(amount!));
setState(() {
qrResponse = response;
});
} catch (e) {
print(e);
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
if (qrResponse == null)
Column(
children: [
SizedBox(
width: 220,
child: Row(
children: [
Expanded(
child: TextFormField(
cursorHeight: 28,
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
decoration: const InputDecoration(
label: Text(
"Enter amount",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20),
),
alignLabelWithHint: true,
floatingLabelAlignment: FloatingLabelAlignment.center,
),
onChanged: (value) {
setState(() {
amount = value;
});
},
),
),
const Text(
'USD',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
)
],
),
),
const SizedBox(height: 20),
ElevatedButton(
style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.orange)),
onPressed: () {
getQRFromPlugin();
},
child: const Text('Get QR from B4U'),
),
],
),
if (qrResponse != null)
Column(
children: [
Image.network(qrResponse!.qrPath!),
const Text('Transaction ID:'),
Text(qrResponse!.transactionId!),
const SizedBox(height: 15),
const Text('Amount:'),
Text(qrResponse!.bitcoinAmount!.toString() + ' = ' + amount! + ' USD'),
const SizedBox(height: 15),
],
)
],
),
),
),
);
}
}
// if (qrImage == null)