From a28eb90549785a793c0c8c42cb1dfc26f59d9115 Mon Sep 17 00:00:00 2001 From: Wilberforce Uwadiegwu Date: Wed, 3 Oct 2018 22:26:38 +0100 Subject: [PATCH] Properly formatted .dart files --- example/lib/main.dart | 50 +++++++++++-------- lib/src/model/checkout_response.dart | 5 ++ lib/src/ui/widgets/base_widget.dart | 15 +++--- .../ui/widgets/checkout/card_checkout.dart | 20 +++++--- .../ui/widgets/checkout/checkout_widget.dart | 14 ++++-- 5 files changed, 61 insertions(+), 43 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 0650c93..e9e8465 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -56,7 +56,8 @@ class _HomePageState extends State { @override void initState() { - PaystackPlugin.initialize(publicKey: paystackPublicKey, secretKey: paystackSecretKey); + PaystackPlugin.initialize( + publicKey: paystackPublicKey, secretKey: paystackSecretKey); super.initState(); } @@ -80,21 +81,22 @@ class _HomePageState extends State { child: const Text('Initalize transaction from:'), ), new Expanded( - child: - new Column(mainAxisSize: MainAxisSize.min, children: [ - new RadioListTile( - value: 0, - groupValue: _radioValue, - onChanged: _handleRadioValueChanged, - title: const Text('Local'), - ), - new RadioListTile( - value: 1, - groupValue: _radioValue, - onChanged: _handleRadioValueChanged, - title: const Text('Server'), - ), - ]), + child: new Column( + mainAxisSize: MainAxisSize.min, + children: [ + new RadioListTile( + value: 0, + groupValue: _radioValue, + onChanged: _handleRadioValueChanged, + title: const Text('Local'), + ), + new RadioListTile( + value: 1, + groupValue: _radioValue, + onChanged: _handleRadioValueChanged, + title: const Text('Server'), + ), + ]), ) ], ), @@ -155,7 +157,8 @@ class _HomePageState extends State { : new Column( mainAxisSize: MainAxisSize.min, children: [ - _getPlatformButton('Charge Card', () => _startAfreshCharge()), + _getPlatformButton( + 'Charge Card', () => _startAfreshCharge()), _verticalSizeBox, _border, new SizedBox( @@ -184,7 +187,8 @@ class _HomePageState extends State { }); }, items: banks.map((String value) { - return new DropdownMenuItem( + return new DropdownMenuItem< + CheckoutMethod>( value: _parseStringToMethod(value), child: new Text(value), ); @@ -213,7 +217,8 @@ class _HomePageState extends State { ); } - void _handleRadioValueChanged(int value) => setState(() => _radioValue = value); + void _handleRadioValueChanged(int value) => + setState(() => _radioValue = value); _handleCheckout() async { if (_method == null) { @@ -416,11 +421,12 @@ class _HomePageState extends State { } _updateStatus(String reference, String message) { - _showMessage( - 'Reference: $reference \n\ Response: $message', const Duration(seconds: 7)); + _showMessage('Reference: $reference \n\ Response: $message', + const Duration(seconds: 7)); } - _showMessage(String message, [Duration duration = const Duration(seconds: 4)]) { + _showMessage(String message, + [Duration duration = const Duration(seconds: 4)]) { _scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Text(message), duration: duration, diff --git a/lib/src/model/checkout_response.dart b/lib/src/model/checkout_response.dart index 189045a..2326605 100644 --- a/lib/src/model/checkout_response.dart +++ b/lib/src/model/checkout_response.dart @@ -8,17 +8,22 @@ class CheckoutResponse { /// A user readable message. If the transaction was successful, this returns the /// cause of the error. String message; + /// The card used for the payment. Will return null if the customer didn't use card /// payment PaymentCard card; + /// The bank account used for the payment. Will return null if the customer didn't use /// bank account as a means of payment BankAccount account; + /// Transaction reference. Might return null for failed transaction transactions String reference; + /// The status of the transaction. A successful response returns true and false /// otherwise bool status; + /// The means of payment. It may return [CheckoutMethod.bank] or [CheckoutMethod.card] CheckoutMethod method; diff --git a/lib/src/ui/widgets/base_widget.dart b/lib/src/ui/widgets/base_widget.dart index 04738fa..9e0a9a1 100644 --- a/lib/src/ui/widgets/base_widget.dart +++ b/lib/src/ui/widgets/base_widget.dart @@ -32,8 +32,7 @@ abstract class BaseState extends State { var returnValue = getPopReturnValue(); if (alwaysPop || (returnValue != null && - (returnValue is CheckoutResponse && - returnValue.status == true))) { + (returnValue is CheckoutResponse && returnValue.status == true))) { Navigator.of(context).pop(returnValue); return false; } @@ -56,8 +55,8 @@ abstract class BaseState extends State { child: const Text('No'), isDefaultAction: true, onPressed: () { - Navigator.pop( - context, false); // Pops the confirmation dialog but not the page. + Navigator.pop(context, + false); // Pops the confirmation dialog but not the page. }, ), ], @@ -68,14 +67,14 @@ abstract class BaseState extends State { new FlatButton( child: const Text('NO'), onPressed: () { - Navigator.of(context) - .pop(false); // Pops the confirmation dialog but not the page. + Navigator.of(context).pop( + false); // Pops the confirmation dialog but not the page. }), new FlatButton( child: const Text('YES'), onPressed: () { - Navigator.of(context) - .pop(true); // Returning true to _onWillPop will pop again. + Navigator.of(context).pop( + true); // Returning true to _onWillPop will pop again. }) ], ); diff --git a/lib/src/ui/widgets/checkout/card_checkout.dart b/lib/src/ui/widgets/checkout/card_checkout.dart index ddac5bd..6f1221c 100644 --- a/lib/src/ui/widgets/checkout/card_checkout.dart +++ b/lib/src/ui/widgets/checkout/card_checkout.dart @@ -35,7 +35,8 @@ class CardCheckout extends StatefulWidget { }); @override - _CardCheckoutState createState() => _CardCheckoutState(charge, accessCode, onResponse); + _CardCheckoutState createState() => + _CardCheckoutState(charge, accessCode, onResponse); } class _CardCheckoutState extends BaseCheckoutMethodState { @@ -100,7 +101,8 @@ class _CardCheckoutState extends BaseCheckoutMethodState { _validateReference() { //check for null value, and length and starts with pk_ if (_charge.reference == null || _charge.reference.isEmpty) { - throw new PaystackException('Payment reference cannot be null or empty. If you ' + throw new PaystackException( + 'Payment reference cannot be null or empty. If you ' 'don\' want the plugin to initialize the transaction, then don\'t pass a ' 'private key in ${PaystackPlugin.initialize}'); } @@ -141,7 +143,8 @@ class _CardCheckoutState extends BaseCheckoutMethodState { } try { - http.Response response = await http.post(url, body: body, headers: headers); + http.Response response = + await http.post(url, body: body, headers: headers); if (!mounted) { return; } @@ -210,11 +213,12 @@ class _CardCheckoutState extends BaseCheckoutMethodState { } new MobileTransactionManager( - charge: charge, - context: context, - beforeValidate: (transaction) => handleBeforeValidate(transaction), - onSuccess: (transaction) => handleOnSuccess(transaction), - onError: (error, transaction) => handleOnError(error, transaction)).chargeCard(); + charge: charge, + context: context, + beforeValidate: (transaction) => handleBeforeValidate(transaction), + onSuccess: (transaction) => handleOnSuccess(transaction), + onError: (error, transaction) => handleOnError(error, transaction)) + .chargeCard(); } void handleError(String message, String reference) { diff --git a/lib/src/ui/widgets/checkout/checkout_widget.dart b/lib/src/ui/widgets/checkout/checkout_widget.dart index 13efed1..f13e4f7 100644 --- a/lib/src/ui/widgets/checkout/checkout_widget.dart +++ b/lib/src/ui/widgets/checkout/checkout_widget.dart @@ -50,7 +50,9 @@ class _CheckoutWidgetState extends BaseState _currentIndex = _getCurrentTab(); _showTabs = widget.method == CheckoutMethod.selectable ? true : false; _tabController = new TabController( - vsync: this, length: _methodWidgets.length, initialIndex: _currentIndex); + vsync: this, + length: _methodWidgets.length, + initialIndex: _currentIndex); _tabController.addListener(_indexChange); _animationController = new AnimationController( duration: const Duration(milliseconds: 500), @@ -78,7 +80,8 @@ class _CheckoutWidgetState extends BaseState content: new Container( child: new SingleChildScrollView( child: new Container( - padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0), + padding: + const EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0), child: _showProcessingError() ? _buildErrorWidget() : _paymentSuccessful @@ -109,7 +112,8 @@ class _CheckoutWidgetState extends BaseState children: [ const Text( 'Pay', - style: const TextStyle(fontSize: 14.0, color: Colors.black54), + style: + const TextStyle(fontSize: 14.0, color: Colors.black54), ), new SizedBox( width: 5.0, @@ -138,7 +142,8 @@ class _CheckoutWidgetState extends BaseState isScrollable: true, unselectedLabelColor: Colors.black54, labelColor: MyColors.green, - labelStyle: new TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500), + labelStyle: + new TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500), indicator: new ShapeDecoration( shape: const RoundedRectangleBorder( borderRadius: tabBorderRadius, @@ -327,7 +332,6 @@ class _CheckoutWidgetState extends BaseState onCountdownComplete: () => Navigator.of(context).pop(_response), ); - @override getPopReturnValue() { return _getResponse();