This commit is contained in:
estevez-dev 2019-08-24 15:22:23 +03:00
parent 0815840a9c
commit 916d0b7e3c
2 changed files with 1288 additions and 4 deletions

1232
android/hs_err_pid766.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,8 @@ class PurchasePage extends StatefulWidget {
class _PurchasePageState extends State<PurchasePage> { class _PurchasePageState extends State<PurchasePage> {
bool _loaded = false;
List<ProductDetails> _products;
@override @override
void initState() { void initState() {
@ -19,19 +21,68 @@ class _PurchasePageState extends State<PurchasePage> {
} }
_loadProducts() async { _loadProducts() async {
const Set<String> _kIds = {'flat_white_a_month', 'lunch_a_month22'}; const Set<String> _kIds = {'flat_white_a_month', 'lunch_a_month'};
final ProductDetailsResponse response = await InAppPurchaseConnection.instance.queryProductDetails(_kIds); final ProductDetailsResponse response = await InAppPurchaseConnection.instance.queryProductDetails(_kIds);
if (!response.notFoundIDs.isEmpty) { if (!response.notFoundIDs.isEmpty) {
Logger.d("Not found products: ${response.notFoundIDs}"); Logger.d("Not found products: ${response.notFoundIDs}");
} }
List<ProductDetails> products = response.productDetails; _products = response.productDetails;
for (ProductDetails product in products) { for (ProductDetails product in _products) {
Logger.d("Product: ${product}"); Logger.d("Product: ${product}");
} }
setState(() {
_loaded = true;
});
}
Widget _buildLoading() {
return Text("Loading...");
}
Widget _buildProducts() {
List<Widget> productWidgets = [];
for (ProductDetails product in _products) {
productWidgets.add(
_buildProduct(product)
);
}
return ListView(
scrollDirection: Axis.vertical,
padding: const EdgeInsets.all(10.0),
children: productWidgets
);
}
Widget _buildProduct(ProductDetails product) {
return Card(
child: Flex(
direction: Axis.horizontal,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Column(
children: <Widget>[
Text("${product.title}"),
Text("${product.price}")
],
),
FlatButton(
child: Text("Buy"),
onPressed: () => Logger.d("Buy!"),
)
],
)
);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget body;
if (!_loaded) {
body = _buildLoading();
} else {
body = _buildProducts();
}
return new Scaffold( return new Scaffold(
appBar: new AppBar( appBar: new AppBar(
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){ leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
@ -47,7 +98,8 @@ class _PurchasePageState extends State<PurchasePage> {
) )
], ],
), ),
body: Text("Hi!"), body: body,
); );
} }
} }