Skip to content

Commit 6cfdbdb

Browse files
Update in_app_purchases rebuild script (#2271)
This PR aligns the codebase more closely with the codelab text. ## Pre-launch Checklist - [x] I read the [Effective Dart: Style] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Effective Dart: Style]: https://dart.dev/guides/language/effective-dart/style [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 parent 546a95f commit 6cfdbdb

File tree

127 files changed

+2929
-187
lines changed

Some content is hidden

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

127 files changed

+2929
-187
lines changed

in_app_purchases/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

in_app_purchases/codelab_rebuild.yaml

Lines changed: 18 additions & 90 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-
@@ -43,3 +43,9 @@ app.*.map.json
17+
@@ -43,3 +43,8 @@ app.*.map.json
1818
/android/app/debug
1919
/android/app/profile
2020
/android/app/release
@@ -23,10 +23,9 @@ steps:
2323
+GoogleService-Info.plist
2424
+google-services.json
2525
+ios/firebase_app_id_file.json
26-
+lib/firebase_options.dart
2726
- name: Add app dependencies
2827
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
28+
flutter: pub add cloud_firestore cupertino_icons firebase_auth firebase_core google_sign_in http intl provider
3029
- name: Patch app/pubspec.yaml
3130
path: steps/app/pubspec.yaml
3231
patch-u: |
@@ -39,7 +38,7 @@ steps:
3938
publish_to: 'none'
4039
version: 0.1.0
4140

42-
@@ -27,3 +27,6 @@ dev_dependencies:
41+
@@ -25,3 +25,6 @@ dev_dependencies:
4342

4443
flutter:
4544
uses-material-design: true
@@ -16734,7 +16733,6 @@ steps:
1673416733
assets/*.p8
1673516734
assets/appstore.token
1673616735
assets/service-account*.json
16737-
lib/constants.dart
1673816736
- name: Replace analysis_options.yaml
1673916737
path: steps/dart-backend/analysis_options.yaml
1674016738
replace-contents: |
@@ -17179,6 +17177,18 @@ steps:
1717917177
from: steps
1718017178
to: step_00
1718117179

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

1864018568
void _updateStatus(PurchasableProduct product, ProductStatus status) {

in_app_purchases/complete/app/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ app.*.map.json
4848
GoogleService-Info.plist
4949
google-services.json
5050
ios/firebase_app_id_file.json
51-
lib/firebase_options.dart

in_app_purchases/complete/app/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@
362362
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
363363
CLANG_ENABLE_MODULES = YES;
364364
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
365-
DEVELOPMENT_TEAM = TC87DMJLQP;
366365
ENABLE_BITCODE = NO;
367366
INFOPLIST_FILE = Runner/Info.plist;
368367
LD_RUNPATH_SEARCH_PATHS = (
@@ -542,7 +541,6 @@
542541
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
543542
CLANG_ENABLE_MODULES = YES;
544543
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
545-
DEVELOPMENT_TEAM = TC87DMJLQP;
546544
ENABLE_BITCODE = NO;
547545
INFOPLIST_FILE = Runner/Info.plist;
548546
LD_RUNPATH_SEARCH_PATHS = (
@@ -565,7 +563,6 @@
565563
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
566564
CLANG_ENABLE_MODULES = YES;
567565
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
568-
DEVELOPMENT_TEAM = TC87DMJLQP;
569566
ENABLE_BITCODE = NO;
570567
INFOPLIST_FILE = Runner/Info.plist;
571568
LD_RUNPATH_SEARCH_PATHS = (

in_app_purchases/complete/app/lib/logic/dash_purchases.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: avoid_print
2-
31
import 'dart:async';
42
import 'dart:convert';
53

@@ -19,10 +17,10 @@ import 'firebase_notifier.dart';
1917
class DashPurchases extends ChangeNotifier {
2018
DashCounter counter;
2119
FirebaseNotifier firebaseNotifier;
22-
IAPRepo iapRepo;
2320
StoreState storeState = StoreState.loading;
2421
late StreamSubscription<List<PurchaseDetails>> _subscription;
2522
List<PurchasableProduct> products = [];
23+
IAPRepo iapRepo;
2624

2725
bool get beautifiedDash => _beautifiedDashUpgrade;
2826
bool _beautifiedDashUpgrade = false;
@@ -46,7 +44,6 @@ class DashPurchases extends ChangeNotifier {
4644
notifyListeners();
4745
return;
4846
}
49-
5047
const ids = <String>{
5148
storeKeyConsumable,
5249
storeKeySubscription,
@@ -61,8 +58,8 @@ class DashPurchases extends ChangeNotifier {
6158

6259
@override
6360
void dispose() {
64-
iapRepo.removeListener(purchasesUpdate);
6561
_subscription.cancel();
62+
iapRepo.removeListener(purchasesUpdate);
6663
super.dispose();
6764
}
6865

@@ -129,10 +126,8 @@ class DashPurchases extends ChangeNotifier {
129126
headers: headers,
130127
);
131128
if (response.statusCode == 200) {
132-
print('Successfully verified purchase');
133129
return true;
134130
} else {
135-
print('failed request: ${response.statusCode} - ${response.body}');
136131
return false;
137132
}
138133
}
@@ -142,7 +137,7 @@ class DashPurchases extends ChangeNotifier {
142137
}
143138

144139
void _updateStreamOnError(dynamic error) {
145-
print(error);
140+
//Handle error here
146141
}
147142

148143
void purchasesUpdate() {
@@ -163,21 +158,21 @@ class DashPurchases extends ChangeNotifier {
163158
// purchases page.
164159
if (iapRepo.hasActiveSubscription) {
165160
counter.applyPaidMultiplier();
166-
for (final element in subscriptions) {
161+
for (var element in subscriptions) {
167162
_updateStatus(element, ProductStatus.purchased);
168163
}
169164
} else {
170165
counter.removePaidMultiplier();
171-
for (final element in subscriptions) {
166+
for (var element in subscriptions) {
172167
_updateStatus(element, ProductStatus.purchasable);
173168
}
174169
}
175170

176-
// Set the dash beautifier and show/hide purchased on
171+
// Set the Dash beautifier and show/hide purchased on
177172
// the purchases page.
178173
if (iapRepo.hasUpgrade != _beautifiedDashUpgrade) {
179174
_beautifiedDashUpgrade = iapRepo.hasUpgrade;
180-
for (final element in upgrades) {
175+
for (var element in upgrades) {
181176
_updateStatus(
182177
element,
183178
_beautifiedDashUpgrade

in_app_purchases/complete/app/pubspec.yaml

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

66
environment:
7-
sdk: ^3.6.0-0
7+
sdk: ^3.6.1
88

99
dependencies:
1010
flutter:
1111
sdk: flutter
12-
cloud_firestore: ^5.5.1
12+
cloud_firestore: ^5.6.2
1313
cupertino_icons: ^1.0.8
14-
firebase_auth: ^5.3.4
15-
firebase_core: ^3.8.1
14+
firebase_auth: ^5.4.1
15+
firebase_core: ^3.10.1
1616
google_sign_in: ^6.2.2
17-
http: ^1.2.2
18-
in_app_purchase: ^3.2.0
19-
in_app_purchase_platform_interface: ^1.4.0
17+
http: ^1.3.0
2018
intl: ^0.20.1
2119
provider: ^6.1.2
20+
in_app_purchase: ^3.2.0
2221

2322
dev_dependencies:
2423
flutter_test:
2524
sdk: flutter
2625
flutter_lints: ^5.0.0
26+
in_app_purchase_platform_interface: ^1.4.0
2727

2828
flutter:
2929
uses-material-design: true

in_app_purchases/complete/dart-backend/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ build/
99
assets/*.p8
1010
assets/appstore.token
1111
assets/service-account*.json
12-
lib/constants.dart

in_app_purchases/complete/dart-backend/pubspec.yaml

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

66
environment:
7-
sdk: ^3.6.0-0
7+
sdk: ^3.6.1
88

99
dependencies:
1010
app_store_server_sdk: ^1.2.9
1111
googleapis: ^13.2.0
1212
googleapis_auth: ^1.6.0
13-
http: ^1.2.2
13+
http: ^1.3.0
1414
shelf: ^1.4.0
1515
shelf_router: ^1.1.0
1616

in_app_purchases/step_00/app/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ app.*.map.json
4848
GoogleService-Info.plist
4949
google-services.json
5050
ios/firebase_app_id_file.json
51-
lib/firebase_options.dart

in_app_purchases/step_00/app/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@
362362
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
363363
CLANG_ENABLE_MODULES = YES;
364364
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
365-
DEVELOPMENT_TEAM = TC87DMJLQP;
366365
ENABLE_BITCODE = NO;
367366
INFOPLIST_FILE = Runner/Info.plist;
368367
LD_RUNPATH_SEARCH_PATHS = (
@@ -542,7 +541,6 @@
542541
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
543542
CLANG_ENABLE_MODULES = YES;
544543
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
545-
DEVELOPMENT_TEAM = TC87DMJLQP;
546544
ENABLE_BITCODE = NO;
547545
INFOPLIST_FILE = Runner/Info.plist;
548546
LD_RUNPATH_SEARCH_PATHS = (
@@ -565,7 +563,6 @@
565563
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
566564
CLANG_ENABLE_MODULES = YES;
567565
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
568-
DEVELOPMENT_TEAM = TC87DMJLQP;
569566
ENABLE_BITCODE = NO;
570567
INFOPLIST_FILE = Runner/Info.plist;
571568
LD_RUNPATH_SEARCH_PATHS = (

0 commit comments

Comments
 (0)