mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
PurchaseWidget: Make sure it is still mounted before calling callback
Fixes APP-B1
This commit is contained in:
@ -107,6 +107,12 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
|||||||
if (response.error != null) {
|
if (response.error != null) {
|
||||||
Log.e("IAP queryProductDetails: ${response.error}");
|
Log.e("IAP queryProductDetails: ${response.error}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the widget was removed from the tree while the asynchronous platform
|
||||||
|
// message was in flight, we want to discard the reply rather than calling
|
||||||
|
// setState to update our non-existent appearance.
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
var products = response.productDetails;
|
var products = response.productDetails;
|
||||||
products.sort((a, b) {
|
products.sort((a, b) {
|
||||||
var pa = _fromProductDetail(a);
|
var pa = _fromProductDetail(a);
|
||||||
@ -122,11 +128,6 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
|||||||
widget.minPurchaseOptionCallback(products.first.price);
|
widget.minPurchaseOptionCallback(products.first.price);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the widget was removed from the tree while the asynchronous platform
|
|
||||||
// message was in flight, we want to discard the reply rather than calling
|
|
||||||
// setState to update our non-existent appearance.
|
|
||||||
if (!mounted) return;
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_products = products;
|
_products = products;
|
||||||
_selectedProduct = _products.isNotEmpty ? _products.first : null;
|
_selectedProduct = _products.isNotEmpty ? _products.first : null;
|
||||||
|
Reference in New Issue
Block a user