korapay_flutter 0.4.0
korapay_flutter: ^0.4.0 copied to clipboard
Korapay payment gateway integration for Flutter.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:developer' as developer;
import 'package:korapay_flutter/korapay_flutter.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter/services.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'dart:async';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Korapay Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: 'Averta',
primaryColor: const Color(0xFF49ceb0),
colorScheme: ColorScheme.light(
primary: const Color(0xFF49ceb0),
secondary: const Color(0xFF989898),
),
scaffoldBackgroundColor: Colors.white,
textTheme: const TextTheme(
titleLarge: TextStyle(fontWeight: FontWeight.w600),
titleMedium: TextStyle(fontWeight: FontWeight.w500),
labelLarge: TextStyle(fontWeight: FontWeight.w500),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: Colors.grey.shade50,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(color: Color(0xFF49ceb0), width: 1.5),
),
labelStyle: TextStyle(
fontFamily: 'Averta',
color: Colors.grey.shade700,
fontSize: 16,
),
hintStyle: TextStyle(
fontFamily: 'Averta',
color: Colors.grey.shade500,
fontSize: 14,
),
floatingLabelStyle: const TextStyle(
fontFamily: 'Averta',
color: Color(0xFF49ceb0),
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF49ceb0),
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
cardTheme: CardTheme(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: Colors.grey.shade200),
),
color: Colors.white,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.white,
foregroundColor: Color(0xFF989898),
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle.dark,
),
snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Korapay Flutter Demo',
style: TextStyle(
fontFamily: 'Averta',
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
backgroundColor: const Color(0xFF49ceb0),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Welcome to Korapay Flutter SDK',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Color(0xFF49ceb0),
),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
const Text(
'This example demonstrates how to integrate the Korapay Flutter SDK in your app using our pre-built payment UI.',
style: TextStyle(
fontSize: 16,
color: Colors.black87,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const KorapayPaymentPage(
publicKey: 'pk_test_4wrQJedRa2GhJsiHFdtEYBN5EWrDSDviZpmuA1sJ',
title: 'Payment for Product',
description: 'Test payment from Flutter SDK',
),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF49ceb0),
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
textStyle: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
child: const Text('Proceed to Payment'),
),
],
),
),
),
);
}
}