Directory Portals: A Guide to The Quick Start To Flutter
In Dart, strings are sequences encoded in UTF-16.
Creating a string
var s1 = 'Single quotes work well for string literals.';
var s2 = "Double quotes work just as well.";
var s3 = 'It\'s easy to escape the string delimiter.';
var s4 = "It's even easier to use the other delimiter.";
var s5 = '''
You can create
multi-line strings like this one.
'''
Copy the code
toString()
All objects have a function toString().
Var intString = 3.1415. The toString ();Copy the code
Embed an expression in a string
You can easily embed an expression in a string using the ${expression} format.
CoorChice likes this feature.
var s = 'string interpolation';
s = 'That deserves all caps.${s.toUpperCase()} is very handy! '
>>>
That deserves all caps.STRING INTERPOLATION is very handy!
Copy the code
Reference variables in a string
Dart supports direct references to variables in strings, in the $value format.
var num = 1000;
var tips = 'The user num is $num.';
print(tips);
>>>
The user num is 1000.
Copy the code
Creates a single-line string
With the r prefix, you can create a mandatory single-line string.
// do not use r var s ='In a raw string, not even \ngets special treatment.'; >>> In a raw string, not even gets special treatment'In a raw string, not even \ngets special treatment.';
>>>
In a raw string, not even \ngets special treatment.
Copy the code
String comparison
In Dart, two strings can be compared using the == operator:
String s1 = 'This is String';
var s2 = 'This is String';
print(s1 == s2);
>>>
trueCopy the code
Directory Portals: A Guide to The Quick Start To Flutter
How can I be found?
Portal:CoorChice homepage
Portal:Lot of CoorChice