payment_lib 0.0.4+8 payment_lib: ^0.0.4+8 copied to clipboard
Flutter Widgets that make it easy to implement Payment Lib to your Flutter App.
import 'package:flutter/material.dart';
import 'package:payment_lib/payment_lib.dart';
import 'package:payment_lib_example/payment_summary_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const PaymentSummaryPage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final selectPaymentMethod = ValueNotifier<String?>(null);
final selectId = ValueNotifier<String?>(null);
final showButton = ValueNotifier(false);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Payment Lib Example'),
),
body: PaymentMethodListView(
selectId: selectId,
paymentMethod: paymentMethodList,
selectPaymentMethod: selectPaymentMethod,
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const PaymentSummaryPage())),
),
//* without PaymentMethodListView
// body: SafeArea(
// child: ValueListenableBuilder(
// valueListenable: selectPaymentMethod,
// builder: (context, _, __) => Column(
// children: [
// Expanded(
// child: ListView.builder(
// itemCount: paymentMethodList.length,
// itemBuilder: (context, i) => PaymentMethodCard(
// selectPaymentMethod: selectPaymentMethod,
// categoryName: paymentMethodList[i].paymentTypes.name,
// payments: paymentMethodList[i].payments,
// onChanged: (id) {
// selectPaymentMethod.value = id!;
// log(selectPaymentMethod.value!);
// },
// ),
// ),
// ),
// if (selectPaymentMethod.value != null)
// SizedBox(
// width: double.infinity,
// child: Card(
// margin: EdgeInsets.zero,
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: ElevatedButton(
// style: ElevatedButton.styleFrom(
// minimumSize: const Size(double.infinity, 45)),
// onPressed: () {},
// child: Text("Pilih",
// style: Theme.of(context)
// .textTheme
// .button!
// .copyWith(color: Colors.white)),
// ),
// ),
// ),
// )
// ],
// ),
// ),
// ),
);
}
}
// //! dummy models
class PaymentMethodModel {
final String iconUrl;
final String name;
final String description;
final String id;
final String paymentTypeId;
final bool active;
PaymentMethodModel({
required this.iconUrl,
required this.name,
required this.description,
required this.id,
required this.paymentTypeId,
required this.active,
});
}
class PaymentsDummy {
PaymentsDummy({required this.paymentTypes, required this.payments});
final PaymentTypes paymentTypes;
final List<PaymentMethodModel> payments;
}
class PaymentTypes {
final String id;
final String name;
PaymentTypes({
required this.id,
required this.name,
});
}
final List<PaymentsDummy> paymentMethodList = [
PaymentsDummy(
paymentTypes: PaymentTypes(id: '11', name: 'Virtual Account'),
payments: [
PaymentMethodModel(
active: true,
paymentTypeId: 'a',
iconUrl:
'https://brandslogos.com///wp-content///uploads///images///large///bca-bank-central-asia-logo.png',
name: 'Bank BCA',
description: 'Bayar melalui ATM atau internet banking',
id: '1'),
PaymentMethodModel(
active: true,
paymentTypeId: 'b',
iconUrl:
'https://3.bp.blogspot.com/-T0htKAVwhFY/WgO3xeAGgNI/AAAAAAAAEoI/Bkm5sC20cNImE1gKgb29BgCNm3138PelwCLcBGAs/w1200-h630-p-k-no-nu/bni.jpg',
name: 'Bank BNI',
description: 'Bayar melalui ATM atau internet banking',
id: '2'),
PaymentMethodModel(
paymentTypeId: 'c',
active: true,
iconUrl:
'https://www.bankmandiri.co.id/documents/20143/44881086/ag-branding-logo-1.png/842d8cf8-b7fb-3014-9620-21f0f88d8377?t=1623309819034',
name: 'Bank Mandiri',
description: 'Bayar melalui ATM atau internet banking',
id: '3'),
PaymentMethodModel(
paymentTypeId: 'd',
active: true,
iconUrl:
'https://ver02.rumahpiatu.org/wp-content/uploads/2020/04/logo-bri.png',
name: 'Bank BRI',
description: 'Bayar melalui ATM atau internet banking',
id: '4'),
PaymentMethodModel(
active: true,
paymentTypeId: 'e',
iconUrl:
'https://1.bp.blogspot.com/-JzE0sLzAWHo/YOe2f1p3GMI/AAAAAAAAIuc/Q025IJ3aAREYqHaATcrbFnaC3ZpV-OOUQCLcBGAsYHQ/s1222/logo-bank-jago.png',
name: 'Bank Jago',
description: 'Bayar melalui ATM atau internet banking',
id: '5'),
]),
PaymentsDummy(
paymentTypes: PaymentTypes(id: '22', name: 'Pembayaran via E-Wallet'),
payments: [
PaymentMethodModel(
active: true,
paymentTypeId: 'f',
iconUrl:
'https://1.bp.blogspot.com/-zqvCZXYnnfA/XciTU6Ikw_I/AAAAAAAABJc/TrUNMleviBsRtXgnDWzFEhZjxN03ET7_gCLcBGAsYHQ/s1600/Logo%2BOVO.png',
name: 'OVO',
description: 'Bayar melalui ATM atau internet banking',
id: '7'),
PaymentMethodModel(
active: true,
paymentTypeId: 'g',
iconUrl:
'https://www.rajabeli.com/wp-content/uploads/2020/07/applikasi-gopay.png',
name: 'Gopay',
description: 'Bayar melalui ATM atau internet banking',
id: '8'),
],
),
PaymentsDummy(
paymentTypes: PaymentTypes(id: '33', name: 'Pembayaran Gerai Retail'),
payments: [
PaymentMethodModel(
active: true,
paymentTypeId: 'h',
iconUrl:
'https://upload.wikimedia.org/wikipedia/commons/9/9e/ALFAMART_LOGO_BARU.png',
name: 'Alfamart',
description: 'Bayar melalui Alfamart',
id: '9'),
PaymentMethodModel(
active: true,
paymentTypeId: 'j',
iconUrl:
'https://upload.wikimedia.org/wikipedia/id/thumb/0/04/Logo_Indomaret.svg/1200px-Logo_Indomaret.svg.png',
name: 'Indomaret',
description: 'Bayar melalui Indomaret',
id: '6'),
],
),
];