toJSON method Null safety

dynamic toJSON()

Implementation

toJSON() {
  final String _json = jsonEncode({
    'address': uint8ListToHex(address!),
    'type': type,
    'timestamp': timestamp,
    'data': {
      'content': uint8ListToHex(data!.content!),
      'code': utf8.decode(data!.code!),
      'keys': {
        'secret': uint8ListToHex(data!.keys!.secret!),
        'authorizedKeys': hexAuthorizedKeys(data!.keys!.authorizedKeys!)
      },
      'ledger': {
        'uco': {
          'transfers':
              List<dynamic>.from(data!.ledger!.uco!.transfers!.map((x) {
            return {
              'to': uint8ListToHex(x.to!),
              'amount': x.amount,
            };
          }))
        },
        'nft': {
          'transfers':
              List<dynamic>.from(data!.ledger!.nft!.transfers!.map((x) {
            return {
              'to': uint8ListToHex(x.to!),
              'amount': x.amount,
              'nft': uint8ListToHex(x.nft!)
            };
          }))
        },
      },
      'recipients': List<dynamic>.from(data!.recipients!.map((x) => x)),
    },
    'previousPublicKey': uint8ListToHex(previousPublicKey!),
    'previousSignature': uint8ListToHex(previousSignature!),
    'originSignature': originSignature == null
        ? originSignature
        : uint8ListToHex(originSignature!)
  });
  return _json;
}