From 3b958007419bf3f1164aa0ab6fd68d84b5830133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Thu, 3 Nov 2022 17:51:54 +0800 Subject: Use less temporary vars --- midtrans.dart | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'midtrans.dart') diff --git a/midtrans.dart b/midtrans.dart index 2746042..8779153 100644 --- a/midtrans.dart +++ b/midtrans.dart @@ -28,41 +28,37 @@ class Midtrans { Midtrans(String apiKey, String pem) { final apiKeyUtf8 = apiKey.toNativeUtf8(); final pemUtf8 = pem.toNativeUtf8(); - final midtrans_init = dylib.lookupFunction + dylib.lookupFunction , Pointer), void Function(Pointer, Pointer)> - ('midtrans_init'); - midtrans_init(apiKeyUtf8, pemUtf8); + ('midtrans_init')(apiKeyUtf8, pemUtf8); calloc.free(apiKeyUtf8); calloc.free(pemUtf8); } String status(String orderID) { - final midtrans_status = dylib.lookupFunction('midtrans_status'); final order_id = orderID.toNativeUtf8(); - final status = midtrans_status(order_id).toDartString(); + final status = dylib.lookupFunction + + ('midtrans_status')(order_id).toDartString(); calloc.free(order_id); return status; } String chargeBanktransfer(String bank, String orderID, int grossAmount) { - final midtrans_banktransfer_new = dylib.lookupFunction - - ('midtrans_banktransfer_new'); - final midtrans_transaction_new = dylib.lookupFunction - , Long), - MidtransTransaction Function(Pointer, int)> - ('midtrans_transaction_new'); - final midtrans_charge = dylib.lookupFunction - - ('midtrans_charge_banktransfer'); final bankUtf8 = bank.toNativeUtf8(); final order_id = orderID.toNativeUtf8(); - final vaNumber = midtrans_charge( - midtrans_banktransfer_new(bankUtf8), - midtrans_transaction_new(order_id, grossAmount)) + final vaNumber = dylib.lookupFunction + + ('midtrans_charge_banktransfer') + (dylib.lookupFunction + + ('midtrans_banktransfer_new')(bankUtf8), + dylib.lookupFunction + , Long), + MidtransTransaction Function (Pointer, int)> + ('midtrans_transaction_new')(order_id, grossAmount)) .toDartString(); calloc.free(bankUtf8); calloc.free(order_id); @@ -70,8 +66,7 @@ class Midtrans { } void cleanup() { - final midtrans_cleanup = dylib.lookupFunction('midtrans_cleanup'); - midtrans_cleanup(); + dylib.lookupFunction + ('midtrans_cleanup')(); } } -- cgit v1.2.3