nomba_flutter 1.0.0
nomba_flutter: ^1.0.0 copied to clipboard
A Flutter plugin that provides payment options to business to accept payments from their users.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:nomba_flutter/nomba_flutter.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';
final _nombaFlutterPlugin = NombaFlutter();
@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 {
platformVersion =
await _nombaFlutterPlugin.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// 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;
});
}
String? result;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text('Running on: $_platformVersion\n'),
TextButton(onPressed: () async{
final request = NombaManagerRequest(
accountId: "bd19897a-7249-43a9-8d63-4a4ce26f8e95",
amount: 10,
clientId: "24b130e8-817c-4ba7-9197-96d19d803ace",
customerName: "Damilola Adeniyi",
orderReference: "order_${DateTime.now().millisecondsSinceEpoch}",
email: "ayodeji.adeniyi@nomba.com",
logo: 'assets/nomba.png',
);
try {
final response = await NombaFlutter.instance.init(request: request);
setState(() {
result = response.toJson().toString();
});
} catch (e) {
print(e);
}
}, child: Text("Start Nomba"),),
if(result!=null) Text(result!)
],
),
),
),
),
);
}
}
//