Skip to content

Commit 64dec00

Browse files
committed
Apply dart format
1 parent 48bd5a1 commit 64dec00

File tree

10 files changed

+212
-277
lines changed

10 files changed

+212
-277
lines changed

lib/enums.dart

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ enum SubscriptionState {
7474
}
7575

7676
/// Transaction states
77-
enum TransactionState {
78-
purchasing,
79-
purchased,
80-
failed,
81-
restored,
82-
deferred,
83-
}
77+
enum TransactionState { purchasing, purchased, failed, restored, deferred }
8478

8579
/// Platform availability types
8680
enum ProductAvailability {
@@ -91,35 +85,16 @@ enum ProductAvailability {
9185
}
9286

9387
/// In-app message types
94-
enum InAppMessageType {
95-
purchase,
96-
billing,
97-
price,
98-
generic,
99-
}
88+
enum InAppMessageType { purchase, billing, price, generic }
10089

10190
/// Refund types
102-
enum RefundType {
103-
issue,
104-
priceChange,
105-
preference,
106-
}
91+
enum RefundType { issue, priceChange, preference }
10792

10893
/// Offer types
109-
enum OfferType {
110-
introductory,
111-
promotional,
112-
code,
113-
winBack,
114-
}
94+
enum OfferType { introductory, promotional, code, winBack }
11595

11696
/// Billing client state
117-
enum BillingClientState {
118-
disconnected,
119-
connecting,
120-
connected,
121-
closed,
122-
}
97+
enum BillingClientState { disconnected, connecting, connected, closed }
12398

12499
/// Proration mode (Android)
125100
enum ProrationMode {
@@ -157,11 +132,7 @@ enum ResponseCodeAndroid {
157132
}
158133

159134
/// See also https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState
160-
enum PurchaseState {
161-
pending,
162-
purchased,
163-
unspecified,
164-
}
135+
enum PurchaseState { pending, purchased, unspecified }
165136

166137
/// Android Proration Mode
167138
enum AndroidProrationMode {

lib/errors.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ class ErrorCodeUtils {
196196
}
197197

198198
/// Maps an ErrorCode enum to platform-specific code
199-
static dynamic toPlatformCode(
200-
ErrorCode errorCode,
201-
IAPPlatform platform,
202-
) {
199+
static dynamic toPlatformCode(ErrorCode errorCode, IAPPlatform platform) {
203200
if (platform == IAPPlatform.ios) {
204201
return ErrorCodeMapping.ios[errorCode] ?? 0;
205202
} else {
@@ -208,10 +205,7 @@ class ErrorCodeUtils {
208205
}
209206

210207
/// Checks if an error code is valid for the specified platform
211-
static bool isValidForPlatform(
212-
ErrorCode errorCode,
213-
IAPPlatform platform,
214-
) {
208+
static bool isValidForPlatform(ErrorCode errorCode, IAPPlatform platform) {
215209
if (platform == IAPPlatform.ios) {
216210
return ErrorCodeMapping.ios.containsKey(errorCode);
217211
} else {
@@ -229,9 +223,7 @@ class ConnectionResult {
229223
ConnectionResult.fromJSON(Map<String, dynamic> json)
230224
: msg = json['msg'] as String?;
231225

232-
Map<String, dynamic> toJson() => {
233-
'msg': msg ?? '',
234-
};
226+
Map<String, dynamic> toJson() => {'msg': msg ?? ''};
235227

236228
@override
237229
String toString() {

lib/events.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ class ConnectionStateEvent {
4141
final bool isConnected;
4242
final String? message;
4343

44-
ConnectionStateEvent({
45-
required this.isConnected,
46-
this.message,
47-
});
44+
ConnectionStateEvent({required this.isConnected, this.message});
4845
}
4946

5047
/// Event listener subscription

lib/flutter_inapp_purchase.dart

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class FlutterInappPurchase
8888
http.Client get _client => _httpClient;
8989

9090
FlutterInappPurchase({Platform? platform, http.Client? client})
91-
: _pf = platform ?? const LocalPlatform(),
92-
_httpClient = client ?? http.Client();
91+
: _pf = platform ?? const LocalPlatform(),
92+
_httpClient = client ?? http.Client();
9393

9494
@visibleForTesting
9595
FlutterInappPurchase.private(Platform platform, {http.Client? client})
96-
: _pf = platform,
97-
_httpClient = client ?? http.Client();
96+
: _pf = platform,
97+
_httpClient = client ?? http.Client();
9898

9999
// Implement the missing method from iOS mixin
100100
@override
@@ -282,9 +282,8 @@ class FlutterInappPurchase
282282
);
283283
}
284284

285-
final sku = androidRequest.skus.isNotEmpty
286-
? androidRequest.skus.first
287-
: '';
285+
final sku =
286+
androidRequest.skus.isNotEmpty ? androidRequest.skus.first : '';
288287
if (type == iap_types.PurchaseType.subs) {
289288
await requestSubscription(
290289
sku,
@@ -349,21 +348,21 @@ class FlutterInappPurchase
349348
: null,
350349
android: _platform.isAndroid
351350
? (type == iap_types.PurchaseType.subs
352-
? iap_types.RequestSubscriptionAndroid(
353-
skus: [sku],
354-
obfuscatedAccountIdAndroid: obfuscatedAccountIdAndroid,
355-
obfuscatedProfileIdAndroid: obfuscatedProfileIdAndroid,
356-
isOfferPersonalized: isOfferPersonalized,
357-
purchaseTokenAndroid: purchaseToken,
358-
replacementModeAndroid: replacementModeAndroid,
359-
subscriptionOffers: subscriptionOffers ?? [],
360-
)
361-
: iap_types.RequestPurchaseAndroid(
362-
skus: [sku],
363-
obfuscatedAccountIdAndroid: obfuscatedAccountIdAndroid,
364-
obfuscatedProfileIdAndroid: obfuscatedProfileIdAndroid,
365-
isOfferPersonalized: isOfferPersonalized,
366-
))
351+
? iap_types.RequestSubscriptionAndroid(
352+
skus: [sku],
353+
obfuscatedAccountIdAndroid: obfuscatedAccountIdAndroid,
354+
obfuscatedProfileIdAndroid: obfuscatedProfileIdAndroid,
355+
isOfferPersonalized: isOfferPersonalized,
356+
purchaseTokenAndroid: purchaseToken,
357+
replacementModeAndroid: replacementModeAndroid,
358+
subscriptionOffers: subscriptionOffers ?? [],
359+
)
360+
: iap_types.RequestPurchaseAndroid(
361+
skus: [sku],
362+
obfuscatedAccountIdAndroid: obfuscatedAccountIdAndroid,
363+
obfuscatedProfileIdAndroid: obfuscatedProfileIdAndroid,
364+
isOfferPersonalized: isOfferPersonalized,
365+
))
367366
: null,
368367
);
369368

@@ -1215,8 +1214,7 @@ class FlutterInappPurchase
12151214
purchase.transactionDate!,
12161215
);
12171216
if (difference.inMinutes <= (duration + grace).inMinutes &&
1218-
purchase.productId == sku)
1219-
return true;
1217+
purchase.productId == sku) return true;
12201218
}
12211219

12221220
return false;
@@ -1285,12 +1283,12 @@ class FlutterInappPurchase
12851283
try {
12861284
final result = await channel
12871285
.invokeMethod<Map<dynamic, dynamic>>('validateReceiptAndroid', {
1288-
'packageName': packageName,
1289-
'productId': productId,
1290-
'productToken': productToken,
1291-
'accessToken': accessToken,
1292-
'isSub': isSub,
1293-
});
1286+
'packageName': packageName,
1287+
'productId': productId,
1288+
'productToken': productToken,
1289+
'accessToken': accessToken,
1290+
'isSub': isSub,
1291+
});
12941292
return result?.cast<String, dynamic>();
12951293
} catch (error) {
12961294
debugPrint('Error validating receipt: $error');

lib/modules/android.dart

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ mixin FlutterInappPurchaseAndroid {
4949
}
5050

5151
try {
52-
final result = await channel.invokeMethod<Map<dynamic, dynamic>>(
53-
'validateReceiptAndroid',
54-
{
55-
'packageName': packageName,
56-
'productId': productId,
57-
'productToken': productToken,
58-
'accessToken': accessToken,
59-
'isSub': isSub,
60-
},
61-
);
52+
final result = await channel
53+
.invokeMethod<Map<dynamic, dynamic>>('validateReceiptAndroid', {
54+
'packageName': packageName,
55+
'productId': productId,
56+
'productToken': productToken,
57+
'accessToken': accessToken,
58+
'isSub': isSub,
59+
});
6260
return result?.cast<String, dynamic>();
6361
} catch (error) {
6462
debugPrint('Error validating receipt: $error');
@@ -77,10 +75,9 @@ mixin FlutterInappPurchaseAndroid {
7775
}
7876

7977
try {
80-
final result = await channel.invokeMethod<bool>(
81-
'acknowledgePurchase',
82-
{'purchaseToken': purchaseToken},
83-
);
78+
final result = await channel.invokeMethod<bool>('acknowledgePurchase', {
79+
'purchaseToken': purchaseToken,
80+
});
8481
return result ?? false;
8582
} catch (error) {
8683
debugPrint('Error acknowledging purchase: $error');
@@ -90,18 +87,15 @@ mixin FlutterInappPurchaseAndroid {
9087

9188
/// Consumes a purchase on Android (for consumable products)
9289
/// @param purchaseToken - The purchase token to consume
93-
Future<bool> consumePurchaseAndroid({
94-
required String purchaseToken,
95-
}) async {
90+
Future<bool> consumePurchaseAndroid({required String purchaseToken}) async {
9691
if (!_isAndroid) {
9792
return false;
9893
}
9994

10095
try {
101-
final result = await channel.invokeMethod<bool>(
102-
'consumePurchase',
103-
{'purchaseToken': purchaseToken},
104-
);
96+
final result = await channel.invokeMethod<bool>('consumePurchase', {
97+
'purchaseToken': purchaseToken,
98+
});
10599
return result ?? false;
106100
} catch (error) {
107101
debugPrint('Error consuming purchase: $error');
@@ -121,8 +115,9 @@ mixin FlutterInappPurchaseAndroid {
121115

122116
final List<dynamic> messages = json.decode(result) as List<dynamic>;
123117
return messages
124-
.map((message) =>
125-
InAppMessage.fromMap(message as Map<String, dynamic>))
118+
.map(
119+
(message) => InAppMessage.fromMap(message as Map<String, dynamic>),
120+
)
126121
.toList();
127122
} catch (error) {
128123
debugPrint('Error getting in-app messages: $error');
@@ -140,10 +135,9 @@ mixin FlutterInappPurchaseAndroid {
140135
}
141136

142137
try {
143-
final result = await channel.invokeMethod<bool>(
144-
'showInAppMessages',
145-
{'messageType': messageType.index},
146-
);
138+
final result = await channel.invokeMethod<bool>('showInAppMessages', {
139+
'messageType': messageType.index,
140+
});
147141
return result ?? false;
148142
} catch (error) {
149143
debugPrint('Error showing in-app messages: $error');

lib/modules/ios.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ mixin FlutterInappPurchaseIOS {
7373
}
7474

7575
try {
76-
return await channel.invokeMethod<String>(
77-
'getSubscriptionGroup',
78-
{'sku': sku},
79-
);
76+
return await channel.invokeMethod<String>('getSubscriptionGroup', {
77+
'sku': sku,
78+
});
8079
} catch (error) {
8180
debugPrint('Error getting subscription group: $error');
8281
return null;
@@ -85,7 +84,8 @@ mixin FlutterInappPurchaseIOS {
8584

8685
/// Requests a purchase with offer (iOS 12.2+)
8786
@Deprecated(
88-
'Use requestPurchase() with RequestPurchase object. Will be removed in 6.0.0')
87+
'Use requestPurchase() with RequestPurchase object. Will be removed in 6.0.0',
88+
)
8989
Future<void> requestProductWithOfferIOS(
9090
String sku,
9191
String appAccountToken,
@@ -107,7 +107,8 @@ mixin FlutterInappPurchaseIOS {
107107

108108
/// Requests a purchase with quantity (iOS)
109109
@Deprecated(
110-
'Use requestPurchase() with RequestPurchase object. Will be removed in 6.0.0')
110+
'Use requestPurchase() with RequestPurchase object. Will be removed in 6.0.0',
111+
)
111112
Future<void> requestPurchaseWithQuantityIOS(String sku, int quantity) async {
112113
if (!_isIOS) {
113114
throw PlatformException(
@@ -116,11 +117,10 @@ mixin FlutterInappPurchaseIOS {
116117
);
117118
}
118119

119-
await channel
120-
.invokeMethod('requestPurchaseWithQuantityIOS', <String, dynamic>{
121-
'sku': sku,
122-
'quantity': quantity,
123-
});
120+
await channel.invokeMethod(
121+
'requestPurchaseWithQuantityIOS',
122+
<String, dynamic>{'sku': sku, 'quantity': quantity},
123+
);
124124
}
125125

126126
/// Gets the iOS app store country code
@@ -185,8 +185,9 @@ mixin FlutterInappPurchaseIOS {
185185
}
186186

187187
try {
188-
final result = await channel
189-
.invokeMethod<Map<dynamic, dynamic>>('getAppTransaction');
188+
final result = await channel.invokeMethod<Map<dynamic, dynamic>>(
189+
'getAppTransaction',
190+
);
190191
return result?.cast<String, dynamic>();
191192
} catch (error) {
192193
debugPrint('Error getting app transaction: $error');

0 commit comments

Comments
 (0)