Reputation: 2000
I am unable to set a string with special characters. It is working fine if I only set a string.
I have written this line:
static var var1 = "s$kncsfiu(AKdhjkhj^sjffhj&jh%";
Any clues how can I set this variable value in Dart flutter?
Upvotes: 1
Views: 486
Reputation: 31219
$
is used in strings for when you want to insert the value of a variable directly into your string. If you want to write $
in your string, you need to escape it like:
static var var1 = "s\$kncsfiu(AKdhjkhj^sjffhj&jh%";
Or do it with marking your string as a "raw" string which disable features like the $
variable replacement:
static var var1 = r"s$kncsfiu(AKdhjkhj^sjffhj&jh%";
For more information, please read the following section in the Dart Language Tour: https://dart.dev/guides/language/language-tour#strings
Upvotes: 2