Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prepare string variable format in flutter? [duplicate]

Tags:

flutter

dart

I want to pass Roll_no to my rest API ? I want pass Roll_no like this format:

String roll_no = '3250$10';

How to prepare this format? I have add $ between 3250 and 10 but it gives error like Expected an identifier.

like image 359
shilpa navale Avatar asked Dec 21 '25 08:12

shilpa navale


1 Answers

If you are attempting to put a String variable inside another static String you can do the following for simple variables:

String firstString = 'sentence';
String secondString = 'This is a $firstString';

Which will output This is a sentence.

If the String is a property of an object, then you must use ${}like this:

person.name = 'Shilpa';
String newString = 'This is my name: ${person.name}';

Which will output This is my name: Shilpa.

like image 142
João Soares Avatar answered Dec 24 '25 03:12

João Soares



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!