Skip to content

Commit

Permalink
Removes all analyze warnings (RevenueCat#154)
Browse files Browse the repository at this point in the history
* adds missing docs

* replaces raisedbutton with elevatedbutton
  • Loading branch information
vegaro authored Feb 23, 2021
1 parent 0cb2af8 commit 50365f4
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 8 deletions.
14 changes: 9 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void main() {
));
}

// ignore: public_member_api_docs
class InitialScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MyAppState();
Expand Down Expand Up @@ -61,6 +62,7 @@ class _MyAppState extends State<InitialScreen> {
}
}

// ignore: public_member_api_docs
class UpsellScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _UpsellScreenState();
Expand Down Expand Up @@ -104,8 +106,8 @@ class _UpsellScreenState extends State<UpsellScreen> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
PurchaseButton(package: monthly),
PurchaseButton(package: lifetime)
_PurchaseButton(package: monthly),
_PurchaseButton(package: lifetime)
],
)));
}
Expand All @@ -119,14 +121,15 @@ class _UpsellScreenState extends State<UpsellScreen> {
}
}

class PurchaseButton extends StatelessWidget {
class _PurchaseButton extends StatelessWidget {
final Package package;

PurchaseButton({Key key, @required this.package}) : super(key: key);
// ignore: public_member_api_docs
_PurchaseButton({Key key, @required this.package}) : super(key: key);

@override
Widget build(BuildContext context) {
return RaisedButton(
return ElevatedButton(
onPressed: () async {
try {
PurchaserInfo purchaserInfo =
Expand All @@ -150,6 +153,7 @@ class PurchaseButton extends StatelessWidget {
}
}

// ignore: public_member_api_docs
class CatsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
Expand Down
2 changes: 2 additions & 0 deletions lib/entitlement_info_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class EntitlementInfo {
/// Check the `isActive` property.
final String billingIssueDetectedAt;

/// Construct an EntitlementInfo
EntitlementInfo(
this.identifier,
this.isActive,
Expand All @@ -60,6 +61,7 @@ class EntitlementInfo {
this.unsubscribeDetectedAt,
this.billingIssueDetectedAt);

/// Constructs an EntitlementInfo from a JSON object
factory EntitlementInfo.fromJson(Map<dynamic, dynamic> json) {
var periodType;
switch (json["periodType"] as String) {
Expand Down
1 change: 1 addition & 0 deletions lib/entitlement_infos_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class EntitlementInfos {
/// entitlement identifier.
final Map<String, EntitlementInfo> active;

/// Constructs an EntitlementInfos from a JSON object
EntitlementInfos.fromJson(Map<dynamic, dynamic> json)
: all = (json["all"] as Map<dynamic, dynamic>).map(
(key, value) => MapEntry(key, EntitlementInfo.fromJson(value))),
Expand Down
47 changes: 47 additions & 0 deletions lib/errors.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
import 'package:flutter/services.dart';

/// Different error codes returned by the Purchases functions.
enum PurchasesErrorCode {
/// Unknown error
unknownError,

/// Purchase was cancelled.
purchaseCancelledError,

/// There was a problem with the store.
storeProblemError,

/// The device or user is not allowed to make the purchase.
purchaseNotAllowedError,

/// One or more of the arguments provided are invalid.
purchaseInvalidError,

/// The product is not available for purchase.
productNotAvailableForPurchaseError,

/// This product is already active for the user.
productAlreadyPurchasedError,

/// There is already another active subscriber using the same receipt.
receiptAlreadyInUseError,

/// The receipt is not valid.
invalidReceiptError,

/// The receipt is missing.
missingReceiptFileError,

/// Error performing request.
networkError,

/// There was a credentials issue. Check the message for more info.
invalidCredentialsError,

/// Received malformed response from the backend.
unexpectedBackendResponseError,

/// There is already another active subscriber using the same receipt.
receiptInUseByOtherSubscriberError,

/// The app user id is not valid.
invalidAppUserIdError,

/// The operation is already in progress.
operationAlreadyInProgressError,

/// There was an unknown backend error.
unknownBackendError,

/// Apple Subscription Key is invalid or not present. In order to provide
/// subscription offers, you must first generate a subscription key. Please
/// see https://docs.revenuecat.com/docs/ios-subscription-offers
/// for more info.
invalidAppleSubscriptionKeyError,

/// The User is ineligible for that action.
ineligibleError,

/// App does not have sufficient permissions to make purchases.
insufficientPermissionsError,

/// The payment is pending.
paymentPendingError,

/// One or more of the attributes sent could not be saved.
invalidSubscriberAttributesError
}

Expand Down
1 change: 1 addition & 0 deletions lib/offering_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Offering {
/// Weekly package type configured in the RevenueCat dashboard, if available.
final Package weekly;

/// Constructs an Offering from a JSON object.
Offering.fromJson(Map<dynamic, dynamic> map)
: identifier = map["identifier"],
serverDescription = map['serverDescription'],
Expand Down
1 change: 1 addition & 0 deletions lib/offerings_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Offerings {
/// Map of all Offerings [Offering] objects keyed by their identifier.
final Map<String, Offering> all;

/// Constructs an Offerings object from a JSON object.
Offerings.fromJson(Map<dynamic, dynamic> map)
: current =
map['current'] != null ? Offering.fromJson(map['current']) : null,
Expand Down
1 change: 1 addition & 0 deletions lib/package_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Package {
/// Offering this package belongs to.
final String offeringIdentifier;

/// Constructs a Package from a JSON object.
Package.fromJson(Map<dynamic, dynamic> json)
: identifier = json['identifier'],
packageType = _PackageTypeHelper.getFromString(json['packageType']),
Expand Down
4 changes: 4 additions & 0 deletions lib/product_wrapper.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'discount.dart';

/// Contains all the product details associated with a Store product id
class Product {
/// Product Id.
final String identifier;
Expand All @@ -25,6 +26,7 @@ class Product {
/// Collection of discount offers for a product. Null for Android.
final List<Discount> discounts;

/// Constructs a Product from a JSON object.
Product.fromJson(Map<dynamic, dynamic> json)
: identifier = json['identifier'],
description = json['description'],
Expand All @@ -47,6 +49,7 @@ class Product {
}
}

/// Contains all the introductory information associated with a [Product]
class IntroductoryPrice {
/// Introductory price of a subscription in the local currency.
final double introPrice;
Expand All @@ -70,6 +73,7 @@ class IntroductoryPrice {
/// user will be given the introductory price, such as 3.
final int introPriceCycles;

/// Constructs an IntroductoryPrice from a JSON object.
IntroductoryPrice.fromJson(Map<dynamic, dynamic> json)
: introPrice = json['intro_price'].toDouble(),
introPriceString = json['intro_price_string'],
Expand Down
2 changes: 2 additions & 0 deletions lib/purchaser_info_wrapper.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:purchases_flutter/entitlement_infos_wrapper.dart';
import 'package:purchases_flutter/transaction.dart';

/// Class containing all information regarding the purchaser
class PurchaserInfo {
/// Entitlements attached to this purchaser info
final EntitlementInfos entitlements;
Expand Down Expand Up @@ -52,6 +53,7 @@ class PurchaserInfo {
/// If there are multiple for different platforms, it will point to the device store.
final String managementURL;

/// Constructs a PurchaserInfo from a JSON object.
PurchaserInfo.fromJson(Map<dynamic, dynamic> map)
: entitlements = EntitlementInfos.fromJson(
map["entitlements"] as Map<dynamic, dynamic>),
Expand Down
26 changes: 23 additions & 3 deletions lib/purchases_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import 'object_wrappers.dart';

export 'object_wrappers.dart';

/// Used to handle async updates from [Purchases].
/// Should be implemented to receive updates when the [PurchaserInfo] changes.
typedef void PurchaserInfoUpdateListener(PurchaserInfo purchaserInfo);

/// Entry point for Purchases.
class Purchases {
static final Set<PurchaserInfoUpdateListener> _purchaserInfoUpdateListeners =
Set();
Expand Down Expand Up @@ -531,18 +534,21 @@ class Purchases {
}

/// This class holds the information used when upgrading from another sku.
///
/// [oldSKU] The oldSKU to upgrade from.
/// [prorationMode] The [ProrationMode] to use when upgrading the given oldSKU.
/// To be used with purchaseProduct and purchasePackage.
class UpgradeInfo {
/// The oldSKU to upgrade from.
String oldSKU;

/// The [ProrationMode] to use when upgrading the given oldSKU.
ProrationMode prorationMode;

/// Constructs an UpgradeInfo
UpgradeInfo(this.oldSKU, {this.prorationMode});
}

/// Replace SKU's ProrationMode.
enum ProrationMode {
/// The Upgrade or Downgrade policy is unknown.
unknownSubscriptionUpgradeDowngradePolicy,

/// Replacement takes effect immediately, and the remaining time will be
Expand Down Expand Up @@ -574,14 +580,27 @@ enum PurchaseType {

/// Supported Attribution networks.
enum PurchasesAttributionNetwork {
/// [https://searchads.apple.com/]
appleSearchAds,

/// [https://www.adjust.com/]
adjust,

/// [https://www.appsflyer.com/]
appsflyer,

/// [http://branch.io/]
branch,

/// [http://tenjin.io/]
tenjin,

/// [https://developers.facebook.com/]
facebook
}

/// Possible IntroEligibility status.
/// Use [checkTrialOrIntroductoryPriceEligibility] to determine the eligibility
enum IntroEligibilityStatus {
/// RevenueCat doesn't have enough information to determine eligibility.
introEligibilityStatusUnknown,
Expand All @@ -601,6 +620,7 @@ class IntroEligibility {
/// Description of the status
String description;

/// Constructs an Transaction from a JSON object
IntroEligibility.fromJson(Map<dynamic, dynamic> map)
: status = IntroEligibilityStatus.values[map["status"]],
description = map["description"];
Expand Down
2 changes: 2 additions & 0 deletions lib/transaction.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Represents a purchase transaction
class Transaction {
/// RevenueCat Id associated to the transaction.
final String revenueCatId;
Expand All @@ -8,6 +9,7 @@ class Transaction {
/// Purchase date of the transaction in ISO 8601 format.
final String purchaseDate;

/// Constructs an Transaction from a JSON object
Transaction.fromJson(Map<dynamic, dynamic> map)
: revenueCatId = map["revenueCatId"],
productId = map["productId"],
Expand Down

0 comments on commit 50365f4

Please sign in to comment.