先看来自官网的解释:
A Dart string is a sequence of UTF-16 code units. You can use either single or double quotes to create a string
从上面的文档中发现创建字符串可以使用单引号或者双引号 这点和JavaScript和groovy kotilin一样
例子:
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.";
除此之外我们还可以使用多行,创建多行字符串的另一种方法是:使用带有单引号或双引号的三重引号
void main(){
var s1 = '''
You can create
multi-line strings like this one.
''';
print(s1);
}
打印结果:
You can create
multi-line strings like this one.
除了三个单引号。还可以使用三个双引号
void main(){
var s2 = """This is also a
multi-line strin