0

I made a model in which I go to get the various data, they are all ok except the 'card' in which I cannot save the data to its inside in my Model .. how can I save the data inside the 'card' of the Map you see in the picture?

card

    factory VoucherPdf.fromJson(Map<String, dynamic> json) {
    try {
      return VoucherPdf._(
        id: json.get('id') as int,
        orderId: json.get('order_id') as int,
        quoteId: json.get('quote_id') as int,
        createdAt: json['createdAt'] == null
            ? null
            : DateTime.parse(json.get('createdAt') as String),
        status: json.get('status') as int,
        card: json.get('card') as Map<String, dynamic>,
      );
    } catch (e) {
      logger.e('[VoucherPdf-fromJson] Deserializing error: ${e.oneline}');
      rethrow;
    }
  }
9
  • Are you getting any error? Please share it if you are. Commented Jan 23, 2022 at 15:23
  • @Josteve at the moment no error, but I cannot recall the data inside it, for example 'pdf'. i need to use the data in it but i can't recall it. Commented Jan 23, 2022 at 15:28
  • How are you trying to access pdf? Commented Jan 23, 2022 at 15:30
  • @Josteve final voucherCanUse = widget.voucher.id; Connection() .getGiftCardPdf( giftcardOrderId: voucherCanUse.toString(), userId: ContentBloc().state.userInfo.id.toString(), ) .then( (index) async { var prove = index?.card.m; }, ); i try with ' index?.card. ' but i not find pdf in my propriety.. Commented Jan 23, 2022 at 15:49
  • 1
    Since card is a map, read the pdf like index?.card['pdf'] and not index?.card.pdf Commented Jan 23, 2022 at 15:51

1 Answer 1

1

Since card is a map, read the pdf like index?.card['pdf'] and not index?.card.pdf

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.