foloosi 1.0.5
foloosi: ^1.0.5 copied to clipboard
A new flutter plugin project.
example/lib/main.dart
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:foloosi/foloosi.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
TextEditingController orderIdTextField = TextEditingController();
final key = GlobalKey<ScaffoldState>();
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
if (orderIdTextField.text.trim().isNotEmpty) {
try {
await Foloosi.init("test_\$2y\$10\$nBFlhIbZ0xA1A0.-MPvoP.v45N5oiAJeBPomyWw-dya-GEUtqZKiy");
Foloosi.setLogVisible(true);
var res = {
"orderId": "xmadfadg",
"orderDescription": "hello world",
"orderAmount": double.parse(orderIdTextField.text),
"state": "india",
"postalCode": "23366",
"customColor": "",
"country": "ARE",
"currencyCode": "INR",
"customer": {
"name": "john",
"email": "[email protected]",
"mobile": "9876543210",
"code": "91",
"address": "hello check 123",
"city": "chennai",
}
};
var result = await Foloosi.makePayment(json.encode(res));
if (kDebugMode) {
print(result);
}
} on Exception catch (exception) {
exception.runtimeType;
}
} else {
WidgetsBinding.instance!.addPostFrameCallback(
(_) => key.currentState?.showSnackBar(
const SnackBar(
content: Text("Please enter amount"),
),
),
);
}
// Platform messages may fail, so we use a try/catch PlatformException.
// 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;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
key: key,
appBar: AppBar(
title: const Text('Foloosi Example'),
),
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.all(20),
child: TextField(
controller: orderIdTextField,
keyboardType: TextInputType.number,
decoration: const InputDecoration(hintText: "Enter the amount"),
),
),
InkWell(
onTap: () {
initPlatformState();
},
child: Container(
margin: const EdgeInsets.all(20),
height: 50,
color: Colors.blue,
child: const Center(
child: Text(
"Proceed Payment",
style: TextStyle(color: Colors.white, fontSize: 18),
),
),
),
),
],
),
),
),
);
}
}