Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
productsRequest
method as per Apple docs can be called on any thread (source: https://developer.apple.com/documentation/storekit/skproductsrequestdelegate (please check text in read)).Working with
validProducts
on such thread can cause concurrency issues, such as this one:"Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSArrayM: 0x283ca4090> was mutated while being enumerated.'"**
Moreover, flutter results must be called on platform main thread only (source: https://docs.flutter.dev/development/platform-integration/platform-channels)
"Even though Flutter sends messages to and from Dart asynchronously, whenever you invoke a channel method, you must invoke that method on the platform’s main thread."
To fix these issues I simply wrapped all the code in
dispatch_async(dispatch_get_main_queue, ^{ ... })
.Please pull this fix.