okra_widget 2.0.5-ussd okra_widget: ^2.0.5-ussd copied to clipboard
Okra widget wrapper SDK, used to implement Okra widgets for both IOS and Android applications written in flutter.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:okra_widget/models/okra_handler.dart';
import 'package:okra_widget/okra.dart';
import 'package:okra_widget/okra_widget.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Okra Link Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Okra Test Widget'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Click button to open Okra Widget'),
RaisedButton(
color: Colors.green,
child: Text(
"Click me",
style: TextStyle(color: Colors.white),
),
onPressed: () async {
var okraOptions = {
"key": "4975d560-9979-518e-b552-f33876e3f658",
"token": "5da6358130a943486f33dced",
"products": [
"auth",
"balance",
"identity",
"transactions"
],
"env": "production",
"clientName": "Bassey",
"color" : "#9013FE",
"limit" : "3",
"isCorporate" : false,
"ussd" : true,
"payment" : true,
"charge": {
"type":"one-time",
"amount":"10000",
"note":"",
"currency": "NGN",
"account": "5f450b2689a23801307c8b5b"
},
"connectMessage" : "Which account do you want to connect with?",
"callback_url" : "",
"redirect_url" : "",
"logo" : "https://dash.okra.ng/static/media/okra-logo.514fd943.png",
"widget_success" : "Your account was successfully linked to SwipeNG",
"widget_failed" : "An unknown error occurred, please try again.",
"currency" : "NGN",
"noPeriodic" : true,
"exp" : "",
"success_title" : "null",
"success_message" : "null",
"guarantors" : {
"status": false,
"message": "Okra requires you to add guarantors",
"number": 3,
}
};
OkraHandler reply = await Okra.create(context, okraOptions);
}),
],
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
}