Sitelet https://github.com/flutter/packages/pull/12739
Skip to content

[In_app _purchase] README excerpt examples and changelog - #12739

Merged
auto-submit[bot] merged 9 commits into
flutter:mainfrom
gerardomorales88:in_app_purchase-readme-excerpt-examples-and-changelog
Sep 18, 2026
Merged

auto-submit[bot] merged 9 commits into
flutter:mainfrom
gerardomorales88:in_app_purchase-readme-excerpt-examples-and-changelog

Conversation

@gerardomorales88

@gerardomorales88 gerardomorales88 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Adds a readme_examples.dart file under example/lib for the in_app_purchase package and switches the package README to use <?code-excerpt?>-generated snippets sourced from it, instead of hand-maintained inline code blocks. This keeps the README examples compiling and in sync with the current package API, and removes in_app_purchase's exemption from code-excerpt adoption.

Also fixes several runtime-safety issues in those new excerpts that were flagged in review (missing Platform.isIOS/Platform.isMacOS guards around StoreKit-only APIs, and unsafe null/index access when reading Android subscription offers and StoreKit 2 transactions), and bumps the package version with a CHANGELOG entry for the change.

Addresses the in_app_purchase/in_app_purchase item of flutter/flutter#102679 (that issue tracks many packages, so it should stay open after this merges).

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Test plan

  • dart run script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages=in_app_purchase — no diff after regeneration
  • dart run script/tool/bin/flutter_plugin_tools.dart validate --packages=in_app_purchase — no issues
  • flutter analyze in example/ — no issues
  • dart format --output=none --set-exit-if-changed on the new excerpts file — no changes needed
  • flutter test in the package — all tests pass

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@gerardomorales88
gerardomorales88 marked this pull request as ready for review September 3, 2026 16:57

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the in_app_purchase package's README examples and documentation excerpts to match the current package API, introducing a new readme_examples.dart file to house these code snippets. Feedback on the new file highlights several potential runtime issues, including missing platform guards for iOS/macOS-specific platform additions, a potential out-of-bounds index error when reading transactions, and unsafe null assertions on subscription details for non-subscription products.

Guard StoreKit platform-addition calls with the correct iOS/macOS
platform checks, and avoid unsafe null assertions/index access when
reading Android subscription offers and StoreKit 2 transactions.
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

[x] I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style, or I have commented below to indicate which documented exception this PR falls under1.

I don't see a version change in the PR.

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.

Also, please complete the PR description.

[x] I linked to at least one issue that this PR fixes in the description above.

This step also has not been done.

Marking as a draft; once the PR description is complete and accurate, please mark this as ready for review.

@stuartmorgan-g
stuartmorgan-g marked this pull request as draft September 9, 2026 14:39
The README/doc-excerpt update needs its own release since 3.3.0 is
already published on pub.dev.
@gerardomorales88
gerardomorales88 marked this pull request as ready for review September 9, 2026 16:04
@gerardomorales88

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g Thanks for the feedback — should be addressed now:

  • Bumped the package version to 3.3.1 and gave it its own CHANGELOG entry, since 3.3.0 was already published.
  • Filled in the PR description with an actual explanation of the change and linked [packages] Adopt code-excerpt across all READMEs flutter#102679, which tracks the in_app_purchase/in_app_purchase item this PR addresses.
  • Marked the PR as ready for review.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the in_app_purchase package to version 3.3.1, migrating the README.md code examples to be extracted from a new source file, readme_examples.dart. Feedback on the new example file suggests several improvements to prevent runtime errors and crashes, including adding platform checks for platform-specific APIs (StoreKit 2 and Google Play), wrapping purchase updates in a try-catch block, and safely accessing list elements to avoid a StateError.

Comment thread packages/in_app_purchase/in_app_purchase/README.md
Comment thread packages/in_app_purchase/in_app_purchase/README.md Outdated
Comment thread packages/in_app_purchase/in_app_purchase/README.md Outdated
Comment thread packages/in_app_purchase/in_app_purchase/README.md Outdated
Comment thread packages/in_app_purchase/in_app_purchase/README.md Outdated
Comment thread packages/in_app_purchase/in_app_purchase/README.md Outdated
Comment thread packages/in_app_purchase/in_app_purchase/README.md
Comment thread packages/in_app_purchase/in_app_purchase/README.md
Comment thread packages/in_app_purchase/in_app_purchase/ci_config.yaml Outdated
- Wrap per-purchase processing in a try-catch so one failed purchase
  doesn't block the rest of the batch or throw an unhandled async error.
- Guard StoreKit 2 purchases/transactions with an iOS/macOS platform
  check, and the Google Play subscription upgrade with an Android check.
- Use pricingPhases.firstOrNull instead of .first to avoid a StateError
  on an empty list.
- Restore the surrounding State class context (field, initState,
  dispose) for the purchase-updates snippet instead of showing only
  the inner listen() call.
- Drop the function wrappers added purely to satisfy code-excerpt for
  store-availability, product-query, restore-purchases, and
  purchase-flow, since they added no context the original inline
  snippets didn't already have.
- Restore the platform-specific package imports (in_app_purchase_android,
  in_app_purchase_storekit, store_kit_wrappers, store_kit_2_wrappers)
  that used to be shown inline in each platform-specific example, using
  multi-part code-excerpt regions anchored on the file's real imports.
- Remove ci_config.yaml now that this package no longer needs the
  exempt_from_excerpts override, instead of leaving it with a default
  value and an obsolete TODO.

README regenerated via `dart run script/tool/bin/flutter_plugin_tools.dart
update-excerpts --packages=in_app_purchase`.
@gerardomorales88

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g Thanks for the detailed feedback. All addressed by regenerating the excerpts and README:

  • purchase-updates: restored the surrounding _ExampleAppState class context (field declaration, initState, dispose) instead of showing only the inner listen() call.
  • Dropped the function wrappers that added nothing to store-availability, product-query, restore-purchases, and purchase-flow — those excerpts now show only the statements that were in the original snippets, with the wrapper functions kept in the source file (outside the excerpted region) purely so it compiles.
  • Restored the platform-specific package imports (in_app_purchase_storekit, store_kit_wrappers, store_kit_2_wrappers, in_app_purchase_android, billing_client_wrappers) as real imports in every excerpt that needs them, using multi-part code-excerpt regions anchored on the actual top-of-file imports — so they're guaranteed to stay correct, not just comments.
  • Removed ci_config.yaml entirely now that in_app_purchase no longer needs the exempt_from_excerpts override.

Regenerated with dart run script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages=in_app_purchase, and validate passes clean.

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Sep 15, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 15, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Sep 15, 2026

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good, but has a bunch of analysis issues (see CI failures, or run analysis locally).

avoid_print and public_member_api_docs you can suppress at the file level, and the others should be fixed.

Comment thread packages/in_app_purchase/in_app_purchase/README.md
Suppress avoid_print and public_member_api_docs at the file level,
since they're expected in illustrative example code. Fix the rest:
drop redundant type annotations that the analyzer flags as obvious,
and use the products variable instead of leaving it unused.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 15, 2026
@gerardomorales88

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g Fixed:

  • Added // ignore_for_file: avoid_print, public_member_api_docs to readme_examples.dart for those two.
  • Fixed the rest: dropped the three omit_obvious_local_variable_types violations, and fixed the unused_local_variable warning by actually printing products.

dart analyze example/lib/readme_examples.dart now reports no issues, and the README was regenerated via update-excerpts.

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one small change.

@bparrishMines for secondary review

Comment thread packages/in_app_purchase/in_app_purchase/example/lib/readme_examples.dart Outdated
The print was only there to satisfy the unused_local_variable lint;
it shouldn't be part of the visible README snippet.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 17, 2026
@gerardomorales88

Copy link
Copy Markdown
Contributor Author

@stuartmorgan-g Good catch — moved print(products) to after the #enddocregion product-query marker, so it stays out of the visible README snippet while still satisfying the unused_local_variable lint. Pushed in c59a3b2.

@bparrishMines bparrishMines left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bparrishMines bparrishMines added the CICD Run CI/CD label Sep 18, 2026
@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
@auto-submit
auto-submit Bot merged commit fa7225d into flutter:main Sep 18, 2026
14 checks passed
pull Bot pushed a commit to edisplay/flutter that referenced this pull request Sep 24, 2026
…er#193289)

Roll Packages from c2b58e1a97fb to 431ea69a42e2 (56 revisions)

flutter/packages@c2b58e1...431ea69

2026-09-24 10687576+bparrishMines@users.noreply.github.com [cross_file]
Updates cross_file to a package separated federated plugin
(flutter/packages#11010)
2026-09-23 21270878+elliette@users.noreply.github.com [material_ui]
Remove static access of `copyWith` from `dart fix` golden tests for
`ThemeData/TextTheme` (flutter/packages#12994)
2026-09-23 happytoday83@naver.com [camera_avfoundation] Replace
deprecated high-resolution capture APIs (flutter/packages#12372)
2026-09-23 tarrinneal@gmail.com [pigeon] update nullish checks to use
new isNullish method (flutter/packages#12985)
2026-09-23 katelovett@google.com [ci] Assign batch release PR approver
as reviewer on sync-back PR (flutter/packages#12976)
2026-09-23 kf013099@gmail.com [image_picker] Fix scaling 10-bit images
(flutter/packages#12557)
2026-09-23 kevmoo@users.noreply.github.com [material_ui] Improve
Autocomplete, DrawerHeader, and Tooltip accessibility
(flutter/packages#12918)
2026-09-23 katelovett@google.com [google_fonts] Decouple GoogleFontsLite
for full tree-shaking and add full feature parity
(flutter/packages#12830)
2026-09-23 21270878+elliette@users.noreply.github.com [file_selector]
Ignore flakey `file_selector_android` tests (flutter/packages#12992)
2026-09-23 31859944+LongCatIsLooong@users.noreply.github.com [CI] Remove
bringup from `Mac_arm64 build_all_packages` targets
(flutter/packages#12978)
2026-09-22 1961493+harryterkelsen@users.noreply.github.com [material_ui]
Unskip 5 passing web tests in bottom_app_bar_test and text_field_test
(flutter/packages#12983)
2026-09-22 1961493+harryterkelsen@users.noreply.github.com
[cupertino_ui] Unskip 5 passing web tests in
adaptive_text_selection_toolbar_test and text_field_test
(flutter/packages#12984)
2026-09-22 me@davidmiguel.com [go_router] Fix ShellRoute chrome dropped
from semantics tree by ModalBarrier (flutter/packages#12353)
2026-09-22 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Add contrastLevel for M3 ColorScheme (flutter/packages#12743)
2026-09-22 themis.chatzie@gmail.com [go_router] Preserve nested pushes
during config updates (flutter/packages#12611)
2026-09-22 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 Chip template to use new gen_defaults
(flutter/packages#12847)
2026-09-22 50643541+Mairramer@users.noreply.github.com [material_ui] Fix
LocalHistoryEntry leak when double tapping Drawer scrim
(flutter/packages#12552)
2026-09-22 katelovett@google.com Update suggested reviewers
(flutter/packages#12974)
2026-09-22 fluttergithubbot@gmail.com Sync release-material_ui-1.4.0 to
main (flutter/packages#12966)
2026-09-22 fluttergithubbot@gmail.com Sync release-cupertino_ui-1.1.1 to
main (flutter/packages#12965)
2026-09-21 21270878+elliette@users.noreply.github.com [ci] Update repo
for 3.47 stable release (flutter/packages#12959)
2026-09-21 engine-flutter-autoroll@skia.org Manual roll Flutter from
27fec0e to 4fcd90b (1 revision) (flutter/packages#12904)
2026-09-21 katelovett@google.com Revert "[go_router_builder] Migrate to
material_ui" (flutter/packages#12962)
2026-09-21 31859944+LongCatIsLooong@users.noreply.github.com
[material_ui] Update `material_ui` tests to prevent them from failing
when framework `TextStyle` changes (flutter/packages#12728)
2026-09-21 katelovett@google.com [go_router_builder] Migrate to
material_ui (flutter/packages#12913)
2026-09-21 dkwingsmt@users.noreply.github.com [material_ui,
cupertino_ui] Bump Flutter version from to 3.47 (flutter/packages#12944)
2026-09-21 katelovett@google.com [cupertino_ui] Work around dart2wasm
optional parameter inference bug in example checkbox tests
(flutter/packages#12961)
2026-09-21 katelovett@google.com [cupertino_ui] Work around dart2wasm
optional parameter inference bug in checkbox_test.dart
(flutter/packages#12956)
2026-09-21 victor.orozco@cloudsufi.com [google_sign_in] PR 3/4 Migrate
ViewProvider and GID SDK wrappers from Objective-C to Swift
(flutter/packages#12657)
2026-09-21 victor.orozco@cloudsufi.com [google_sign_in] PR 2/4 Migrate
the plugin class from Objective-C to Swift. (flutter/packages#12655)
2026-09-20 10687576+bparrishMines@users.noreply.github.com
[cross_file_darwin] iOS/macOS implementation of `cross_file`
(flutter/packages#12910)
2026-09-20 10687576+bparrishMines@users.noreply.github.com
[cross_file_web] Web implementation of `cross_file`
(flutter/packages#12908)
2026-09-20 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 `InputChip` template to use new gen_defaults
(flutter/packages#12850)
2026-09-20 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 Checkbox defaults to new gen_defaults
(flutter/packages#12816)
2026-09-20 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Migrate M3 `FilterChip` template to use new gen_defaults
(flutter/packages#12849)
2026-09-19 zengyan@88.com [material_ui] Announce PopupMenuButton with a
child as a button (flutter/packages#12585)
2026-09-19 engine-flutter-autoroll@skia.org Roll Flutter (stable) from
9584c67 to 6a19cca (7 revisions) (flutter/packages#12950)
2026-09-18 21270878+elliette@users.noreply.github.com [material_ui]
Reduce the `material_ui` non-wasm web test suite
(flutter/packages#12763)
2026-09-18 31859944+LongCatIsLooong@users.noreply.github.com Replace
`Mac_x64` builders with `Mac_arm64` ones (flutter/packages#12941)
2026-09-18 32538273+ValentinVignal@users.noreply.github.com
[in_app_purchase_storekit] Use `_$SKPaymentDiscountWrapperToJson`
(flutter/packages#12721)
2026-09-18 gerardo.morales@cloudsufi.com [In_app _purchase] README
excerpt examples and changelog (flutter/packages#12739)
2026-09-18 brunocorona.alcantar@gmail.com [material_ui] Add alternative
input method for `RangeSlider` in `NavigationMode.directional`
(flutter/packages#12630)
2026-09-18 10687576+bparrishMines@users.noreply.github.com
[cross_file_android] Android implementation of `cross_file`
(flutter/packages#12909)
2026-09-18 50643541+Mairramer@users.noreply.github.com
[camera_platform_interface] Adds videoOutputPath support to
startVideoRecording (flutter/packages#12667)
2026-09-17 dkwingsmt@users.noreply.github.com [cupertino_ui] Migrate a
snippet in `CupertinoCheckbox`'s API doc to `{@example}` and add unit
tests (flutter/packages#12180)
2026-09-17 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Default gen_defaults color helper prefix (flutter/packages#12848)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: in_app_purchase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants