Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to access parameters that have a $ in the beginning in Flutter/Dart

I generate an object with parameters. It’s a mix of custom ones that I create (no $) or the SDK that I have integrated generated a bunch with $:

{$campaign_id: 471764, $campaign_name: TPUSA, $channel: email, $first_match: false, $first_match_link: false, $guaranteed_match: true, $link_id: 504455, $link_name: TPUSA Demo, $reinstall: false, $suspicious: false, $token: tpusademo, creatorID: timfong888, referralID: tpusa-demo}

I am able to access the params without $ but get one with it:

socialdata.creator.value = globalReferralData.linkParams['creatorID'];
socialdata.campaign.value = globalReferralData.linkParams['$campaign_id'];

Is there something I need to do to access the values that have $ without an error (I get an error for $campaign_id.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can either escape the $ by putting \ before the $ like: '\$campaign_id'.

Or specify you want a raw string where every character should be read as they are written by putting an r before the string definition like: r'$campaign_id'

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading