getUserOwnedItems method

  1. @override
Future<List<GalaxyOwnedProduct>> getUserOwnedItems(
  1. String productType, {
  2. OperationMode operationMode = OperationMode.test,
})
override

Implementation

@override
Future<List<GalaxyOwnedProduct>> getUserOwnedItems(String productType,
    {OperationMode operationMode = OperationMode.test}) async {
  try {
    final productList =
        await methodChannel.invokeMethod('getUserOwnedItems', {
      'productType': productType,
      'operationMode': operationMode.getName(),
    });
    List<dynamic> jsonList = jsonDecode(productList);
    return jsonList
        .map((product) =>
            GalaxyOwnedProduct.fromJson(product as Map<String, dynamic>))
        .toList();
  } on PlatformException catch (e) {
    throw PlatformException(
      code: e.code,
      message: 'Error while getting user owned items: ${e.message}',
      details: e.details,
    );
  }
}