Skip to content

Commit faf6dbc

Browse files
committed
Update in_app_purchases part 1
1 parent 0bfb040 commit faf6dbc

File tree

208 files changed

+2857
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+2857
-296
lines changed

in_app_purchases/codelab_rebuild.yaml

Lines changed: 23 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
patch-u: |
1515
--- b/in_app_purchases/step_00/app/.gitignore
1616
+++ a/in_app_purchases/step_00/app/.gitignore
17-
@@ -41,3 +41,9 @@ app.*.map.json
17+
@@ -43,3 +43,9 @@ app.*.map.json
1818
/android/app/debug
1919
/android/app/profile
2020
/android/app/release
@@ -26,7 +26,7 @@ steps:
2626
+lib/firebase_options.dart
2727
- name: Add app dependencies
2828
path: steps/app
29-
flutter: pub add cloud_firestore cupertino_icons firebase_auth firebase_core google_sign_in http in_app_purchase in_app_purchase_platform_interface intl provider
29+
flutter: pub add cloud_firestore cupertino_icons firebase_auth firebase_core google_sign_in http intl provider
3030
- name: Patch app/pubspec.yaml
3131
path: steps/app/pubspec.yaml
3232
patch-u: |
@@ -39,7 +39,7 @@ steps:
3939
publish_to: 'none'
4040
version: 0.1.0
4141

42-
@@ -27,3 +27,6 @@ dev_dependencies:
42+
@@ -25,3 +25,6 @@ dev_dependencies:
4343

4444
flutter:
4545
uses-material-design: true
@@ -16720,9 +16720,6 @@ steps:
1672016720
- name: Add dependencies
1672116721
path: steps/dart-backend
1672216722
dart: pub add googleapis googleapis_auth http app_store_server_sdk
16723-
- name: Remove not required dependency
16724-
path: steps/dart-backend
16725-
dart: pub remove args
1672616723
- name: Replace .github
1672716724
path: steps/dart-backend/.gitignore
1672816725
replace-contents: |
@@ -17182,6 +17179,18 @@ steps:
1718217179
from: steps
1718317180
to: step_00
1718417181

17182+
- name: step_03
17183+
steps:
17184+
- name: Remove step_03
17185+
rmdir: step_03
17186+
- name: Add dependencies
17187+
path: steps/app
17188+
flutter: pub add in_app_purchase dev:in_app_purchase_platform_interface
17189+
- name: Copy to step_03
17190+
copydir:
17191+
from: steps
17192+
to: step_03
17193+
1718517194
- name: step_07
1718617195
steps:
1718717196
- name: Remove step_07
@@ -18546,98 +18555,16 @@ steps:
1854618555
from: steps
1854718556
to: step_10
1854818557

18549-
- name: complete
18558+
- name: step_11
1855018559
steps:
18551-
- name: Remove complete
18552-
rmdir: complete
18560+
- name: Remove step_11
18561+
rmdir: step_11
1855318562
- name: Patch app/lib/logic/dash_purchases.dart
1855418563
path: steps/app/lib/logic/dash_purchases.dart
1855518564
patch-u: |
18556-
--- b/in_app_purchases/complete/app/lib/logic/dash_purchases.dart
18557-
+++ a/in_app_purchases/complete/app/lib/logic/dash_purchases.dart
18558-
@@ -1,3 +1,5 @@
18559-
+// ignore_for_file: avoid_print
18560-
+
18561-
import 'dart:async';
18562-
import 'dart:convert';
18563-
18564-
@@ -17,10 +19,10 @@ import 'firebase_notifier.dart';
18565-
class DashPurchases extends ChangeNotifier {
18566-
DashCounter counter;
18567-
FirebaseNotifier firebaseNotifier;
18568-
+ IAPRepo iapRepo;
18569-
StoreState storeState = StoreState.loading;
18570-
late StreamSubscription<List<PurchaseDetails>> _subscription;
18571-
List<PurchasableProduct> products = [];
18572-
- IAPRepo iapRepo;
18573-
18574-
bool get beautifiedDash => _beautifiedDashUpgrade;
18575-
bool _beautifiedDashUpgrade = false;
18576-
@@ -44,6 +46,7 @@ class DashPurchases extends ChangeNotifier {
18577-
notifyListeners();
18578-
return;
18579-
}
18580-
+
18581-
const ids = <String>{
18582-
storeKeyConsumable,
18583-
storeKeySubscription,
18584-
@@ -58,8 +61,8 @@ class DashPurchases extends ChangeNotifier {
18585-
18586-
@override
18587-
void dispose() {
18588-
- _subscription.cancel();
18589-
iapRepo.removeListener(purchasesUpdate);
18590-
+ _subscription.cancel();
18591-
super.dispose();
18592-
}
18593-
18594-
@@ -126,8 +129,10 @@ class DashPurchases extends ChangeNotifier {
18595-
headers: headers,
18596-
);
18597-
if (response.statusCode == 200) {
18598-
+ print('Successfully verified purchase');
18599-
return true;
18600-
} else {
18601-
+ print('failed request: ${response.statusCode} - ${response.body}');
18602-
return false;
18603-
}
18604-
}
18605-
@@ -137,7 +142,7 @@ class DashPurchases extends ChangeNotifier {
18606-
}
18607-
18608-
void _updateStreamOnError(dynamic error) {
18609-
- //Handle error here
18610-
+ print(error);
18611-
}
18612-
18613-
void purchasesUpdate() {
18614-
@@ -158,21 +163,21 @@ class DashPurchases extends ChangeNotifier {
18615-
// purchases page.
18616-
if (iapRepo.hasActiveSubscription) {
18617-
counter.applyPaidMultiplier();
18618-
- for (var element in subscriptions) {
18619-
+ for (final element in subscriptions) {
18620-
_updateStatus(element, ProductStatus.purchased);
18621-
}
18622-
} else {
18623-
counter.removePaidMultiplier();
18624-
- for (var element in subscriptions) {
18625-
+ for (final element in subscriptions) {
18626-
_updateStatus(element, ProductStatus.purchasable);
18627-
}
18628-
}
18629-
18630-
- // Set the Dash beautifier and show/hide purchased on
18631-
+ // Set the dash beautifier and show/hide purchased on
18632-
// the purchases page.
18633-
if (iapRepo.hasUpgrade != _beautifiedDashUpgrade) {
18634-
_beautifiedDashUpgrade = iapRepo.hasUpgrade;
18635-
- for (var element in upgrades) {
18636-
+ for (final element in upgrades) {
18637-
_updateStatus(
18638-
element,
18639-
_beautifiedDashUpgrade
18640-
@@ -184,8 +189,8 @@ class DashPurchases extends ChangeNotifier {
18565+
--- b/in_app_purchases/step_11/app/lib/logic/dash_purchases.dart
18566+
+++ a/in_app_purchases/step_11/app/lib/logic/dash_purchases.dart
18567+
@@ -184,8 +184,8 @@ class DashPurchases extends ChangeNotifier {
1864118568
}
1864218569

1864318570
void _updateStatus(PurchasableProduct product, ProductStatus status) {
@@ -18693,10 +18620,10 @@ steps:
1869318620
expect(token, 'TOKEN');
1869418621
});
1869518622
}
18696-
- name: Copy to complete
18623+
- name: Copy to step_11
1869718624
copydir:
1869818625
from: steps
18699-
to: complete
18626+
to: step_11
1870018627

1870118628
- name: Cleanup
1870218629
steps:

in_app_purchases/complete/app/lib/firebase_options.dart

Lines changed: 0 additions & 69 deletions
This file was deleted.

in_app_purchases/complete/dart-backend/lib/constants.dart

Lines changed: 0 additions & 7 deletions
This file was deleted.

in_app_purchases/step_00/app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

in_app_purchases/step_00/app/pubspec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ publish_to: 'none'
44
version: 0.1.0
55

66
environment:
7-
sdk: ^3.5.4
7+
sdk: ^3.6.0
88

99
dependencies:
1010
flutter:
@@ -15,15 +15,13 @@ dependencies:
1515
firebase_core: ^3.8.1
1616
google_sign_in: ^6.2.2
1717
http: ^1.2.2
18-
in_app_purchase: ^3.2.0
19-
in_app_purchase_platform_interface: ^1.4.0
2018
intl: ^0.20.1
2119
provider: ^6.1.2
2220

2321
dev_dependencies:
2422
flutter_test:
2523
sdk: flutter
26-
flutter_lints: ^4.0.0
24+
flutter_lints: ^5.0.0
2725

2826
flutter:
2927
uses-material-design: true

in_app_purchases/step_00/dart-backend/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 1.0.0
44
# repository: https://github.com/my_org/my_repo
55

66
environment:
7-
sdk: ^3.5.4
7+
sdk: ^3.6.0
88

99
dependencies:
1010
app_store_server_sdk: ^1.2.9
@@ -15,5 +15,5 @@ dependencies:
1515
shelf_router: ^1.1.0
1616

1717
dev_dependencies:
18-
lints: ^4.0.0
18+
lints: ^5.0.0
1919
test: ^1.24.0

in_app_purchases/complete/app/.gitignore renamed to in_app_purchases/step_03/app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

0 commit comments

Comments
 (0)