Skip to content

Commit

Permalink
Properly formatted .dart files
Browse files Browse the repository at this point in the history
  • Loading branch information
wilburx9 committed Oct 3, 2018
1 parent bc520e6 commit a28eb90
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 43 deletions.
50 changes: 28 additions & 22 deletions example/lib/main.dart
Expand Up @@ -56,7 +56,8 @@ class _HomePageState extends State<HomePage> {

@override
void initState() {
PaystackPlugin.initialize(publicKey: paystackPublicKey, secretKey: paystackSecretKey);
PaystackPlugin.initialize(
publicKey: paystackPublicKey, secretKey: paystackSecretKey);
super.initState();
}

Expand All @@ -80,21 +81,22 @@ class _HomePageState extends State<HomePage> {
child: const Text('Initalize transaction from:'),
),
new Expanded(
child:
new Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
new RadioListTile<int>(
value: 0,
groupValue: _radioValue,
onChanged: _handleRadioValueChanged,
title: const Text('Local'),
),
new RadioListTile<int>(
value: 1,
groupValue: _radioValue,
onChanged: _handleRadioValueChanged,
title: const Text('Server'),
),
]),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new RadioListTile<int>(
value: 0,
groupValue: _radioValue,
onChanged: _handleRadioValueChanged,
title: const Text('Local'),
),
new RadioListTile<int>(
value: 1,
groupValue: _radioValue,
onChanged: _handleRadioValueChanged,
title: const Text('Server'),
),
]),
)
],
),
Expand Down Expand Up @@ -155,7 +157,8 @@ class _HomePageState extends State<HomePage> {
: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_getPlatformButton('Charge Card', () => _startAfreshCharge()),
_getPlatformButton(
'Charge Card', () => _startAfreshCharge()),
_verticalSizeBox,
_border,
new SizedBox(
Expand Down Expand Up @@ -184,7 +187,8 @@ class _HomePageState extends State<HomePage> {
});
},
items: banks.map((String value) {
return new DropdownMenuItem<CheckoutMethod>(
return new DropdownMenuItem<
CheckoutMethod>(
value: _parseStringToMethod(value),
child: new Text(value),
);
Expand Down Expand Up @@ -213,7 +217,8 @@ class _HomePageState extends State<HomePage> {
);
}

void _handleRadioValueChanged(int value) => setState(() => _radioValue = value);
void _handleRadioValueChanged(int value) =>
setState(() => _radioValue = value);

_handleCheckout() async {
if (_method == null) {
Expand Down Expand Up @@ -416,11 +421,12 @@ class _HomePageState extends State<HomePage> {
}

_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,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/model/checkout_response.dart
Expand Up @@ -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;

Expand Down
15 changes: 7 additions & 8 deletions lib/src/ui/widgets/base_widget.dart
Expand Up @@ -32,8 +32,7 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
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;
}
Expand All @@ -56,8 +55,8 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
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.
},
),
],
Expand All @@ -68,14 +67,14 @@ abstract class BaseState<T extends StatefulWidget> extends State<T> {
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.
})
],
);
Expand Down
20 changes: 12 additions & 8 deletions lib/src/ui/widgets/checkout/card_checkout.dart
Expand Up @@ -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<CardCheckout> {
Expand Down Expand Up @@ -100,7 +101,8 @@ class _CardCheckoutState extends BaseCheckoutMethodState<CardCheckout> {
_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}');
}
Expand Down Expand Up @@ -141,7 +143,8 @@ class _CardCheckoutState extends BaseCheckoutMethodState<CardCheckout> {
}

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;
}
Expand Down Expand Up @@ -210,11 +213,12 @@ class _CardCheckoutState extends BaseCheckoutMethodState<CardCheckout> {
}

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) {
Expand Down
14 changes: 9 additions & 5 deletions lib/src/ui/widgets/checkout/checkout_widget.dart
Expand Up @@ -50,7 +50,9 @@ class _CheckoutWidgetState extends BaseState<CheckoutWidget>
_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),
Expand Down Expand Up @@ -78,7 +80,8 @@ class _CheckoutWidgetState extends BaseState<CheckoutWidget>
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
Expand Down Expand Up @@ -109,7 +112,8 @@ class _CheckoutWidgetState extends BaseState<CheckoutWidget>
children: <Widget>[
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,
Expand Down Expand Up @@ -138,7 +142,8 @@ class _CheckoutWidgetState extends BaseState<CheckoutWidget>
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,
Expand Down Expand Up @@ -327,7 +332,6 @@ class _CheckoutWidgetState extends BaseState<CheckoutWidget>
onCountdownComplete: () => Navigator.of(context).pop(_response),
);


@override
getPopReturnValue() {
return _getResponse();
Expand Down

0 comments on commit a28eb90

Please sign in to comment.