upi_flutter 0.0.1 upi_flutter: ^0.0.1 copied to clipboard
A new flutter plugin project.
import 'package:flutter/material.dart';
import 'package:upi_flutter/upi_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String data = 'Testing plugin';
@override
void initState() {
super.initState();
}
Future<String> initiateTransaction(String app) async {
UpiFlutter upi = new UpiFlutter(
receiverUpiId: '7014971653@apl',
receiverName: 'Tester',
transactionRefId: 'TestingId',
transactionNote: 'Not actual. Just an example.',
amount: 1.00,
);
String response = await upi.startTransaction();
return response;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
onTap: (){
initiateTransaction("7014971653@ybl").then((onValue){
setState(() {
data = onValue;
});
});
},
child: Container(
width: 150,
height: 50,
color: Colors.grey,
child: Center(child: Text("tap to pay")),
),
),
SizedBox(height: 30,),
Text(data,style: TextStyle(color: Colors.black,fontSize: 20),)
],
),
),
),
);
}
}