Skip to content

Commit

Permalink
Adjust language and encapsulation
Browse files Browse the repository at this point in the history
  • Loading branch information
JlUgia committed Oct 10, 2024
1 parent 34cb000 commit e1cab4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions pay/lib/src/widgets/google_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ class _GooglePayButtonState extends _PayButtonState {
_paymentResultSubscription = eventChannel
.receiveBroadcastStream()
.map((result) => jsonDecode(result as String) as Map<String, dynamic>)
.listen((result) {
widget._deliverPaymentResult(result);
}, onError: (error) {
widget._deliverError(error);
});
.listen(widget._deliverPaymentResult, onError: widget._deliverError);
}

@override
Expand Down
8 changes: 4 additions & 4 deletions pay/lib/src/widgets/pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ abstract class PayButton extends StatefulWidget {
/// [_payButton] is added to the tree. Otherwise, if set, the replacement widget
/// in [childOnError] is shown.
class _PayButtonState extends State<PayButton> {
late final Future<bool> userCanPayFuture;
late final Future<bool> _userCanPayFuture;

Future<bool> userCanPay() async {
Future<bool> _userCanPay() async {
try {
return await widget._payClient.userCanPay(widget.buttonProvider);
} catch (error) {
Expand All @@ -138,7 +138,7 @@ class _PayButtonState extends State<PayButton> {
@override
void initState() {
super.initState();
userCanPayFuture = userCanPay();
_userCanPayFuture = _userCanPay();
}

@override
Expand All @@ -150,7 +150,7 @@ class _PayButtonState extends State<PayButton> {
// Future builder running the `userCanPayFuture` and decides what to show
// based on the result.
return FutureBuilder<bool>(
future: userCanPayFuture,
future: _userCanPayFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == true) {
Expand Down

0 comments on commit e1cab4b

Please sign in to comment.