rabitlala_flutter_sdk 1.0.10
rabitlala_flutter_sdk: ^1.0.10 copied to clipboard
A Flutter SDK for launching RabbitLala secure mobile checkout – ideal for businesses accepting payments.
example/lib/main.dart
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:rabitlala_flutter_sdk/rabbitlala.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
///initialize the sdk
Rabbitlala.init(
mode: ENVModes.demo,
pubKey: "sk_test_f617c0f93f9bea351be36b2cd61ab4447c4e60ce4ab930",
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Rabbitlalas Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xEC34C8DF)),
),
home: const MyHomePage(title: 'RabbitLaLa Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final reference = TextEditingController(text: "L93FS07C02F");
bool isLoading = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child:
isLoading
? CircularProgressIndicator()
: Padding(
padding: const EdgeInsets.all(20),
child: Column(
spacing: 20,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 20),
TextFormField(
controller: reference,
decoration: InputDecoration(
labelText: "Reference",
border: OutlineInputBorder(),
),
),
ElevatedButton(
onPressed: () async {
try {
final response = await Rabbitlala.checkout(
context,
paymentRef: reference.text,
);
log("response:..........$response");
WidgetsBinding.instance.addPostFrameCallback((
_,
) async {
await Future.delayed(Duration(seconds: 3));
setState(() {
isLoading = false;
});
});
} catch (e) {
log("Error launching checkout: $e");
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [Text("Pay")],
),
),
],
),
),
),
);
}
}