Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print message in terminal with concat two strings in flutter?

Tags:

flutter

I knows print() will useful but how to merge or concat two string variables. like print(" "+str1+" "+str2)

like image 947
234 Shk Avatar asked Nov 16 '17 12:11

234 Shk


2 Answers

It is more of a dart question. You can achieve that using:

print('Something $string1 something more ${someObject.string2} even more $string3'); 
like image 59
Arnold Parge Avatar answered Oct 11 '22 13:10

Arnold Parge


In dart there are many string options.

For concatenation, you can do :

  • 'hello $myVariable'
  • "hello ${myVariable.myProperty}"
  • 'hello ' 'world' (only works with string literals)
  • 'hello' + myVariable

So in your case, you can do a print(" $str1 $str2")

Use $var instead of ${var} here

like image 34
Rémi Rousselet Avatar answered Oct 11 '22 12:10

Rémi Rousselet