Skip to content

Commit

Permalink
[in_app_purchase] Update app-facing package to new analysis options (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed Mar 2, 2022
1 parent 5084693 commit 0283a99
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 106 deletions.
4 changes: 4 additions & 0 deletions packages/in_app_purchase/in_app_purchase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.1

* Internal code cleanup for stricter analysis options.

## 3.0.0

* **BREAKING CHANGE** Updates `restorePurchases` to emit an empty list of purchases on StoreKit when there are no purchases to restore (same as Android).
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';

// ignore: avoid_classes_with_only_static_members
/// A store of consumable items.
///
/// This is a development prototype tha stores consumables in the shared
/// preferences. Do not use this in real world apps.
class ConsumableStore {
static const String _kPrefKey = 'consumables';
static Future<void> _writes = Future.value();
static Future<void> _writes = Future<void>.value();

/// Adds a consumable with ID `id` to the store.
///
Expand All @@ -32,19 +33,19 @@ class ConsumableStore {
/// Returns the list of consumables from the store.
static Future<List<String>> load() async {
return (await SharedPreferences.getInstance()).getStringList(_kPrefKey) ??
[];
<String>[];
}

static Future<void> _doSave(String id) async {
List<String> cached = await load();
SharedPreferences prefs = await SharedPreferences.getInstance();
final List<String> cached = await load();
final SharedPreferences prefs = await SharedPreferences.getInstance();
cached.add(id);
await prefs.setStringList(_kPrefKey, cached);
}

static Future<void> _doConsume(String id) async {
List<String> cached = await load();
SharedPreferences prefs = await SharedPreferences.getInstance();
final List<String> cached = await load();
final SharedPreferences prefs = await SharedPreferences.getInstance();
cached.remove(id);
await prefs.setStringList(_kPrefKey, cached);
}
Expand Down
Loading

0 comments on commit 0283a99

Please sign in to comment.