Flutter 如何在终端中打印带有两个字符串的消息?
我知道print()很有用,但是如何合并或合并两个字符串变量。Flutter 如何在终端中打印带有两个字符串的消息?,flutter,Flutter,我知道print()很有用,但是如何合并或合并两个字符串变量。 就像打印一样(“+str1+”+str2)这更像是一个省道问题。 您可以通过以下方式实现: print('Something ${string1} something more ${string2} even more'); 在dart中有许多字符串选项 对于串联,您可以执行以下操作: 'hello$myVariable' “hello${myVariable.myProperty}” 'hello''world'(仅适用于字
就像打印一样(“+str1+”+str2)这更像是一个省道问题。 您可以通过以下方式实现:
print('Something ${string1} something more ${string2} even more');
在dart中有许多字符串选项 对于串联,您可以执行以下操作:
'hello$myVariable'
“hello${myVariable.myProperty}”
(仅适用于字符串文本)'hello''world'
'hello'+myVariable
打印($str1$str2”)
在这里使用$var而不是${var}您的代码应该可以工作,但Arnolds方法是Dart中的预出错方法。