In javascript, if I have 3 variables like this:
var x = 1
var y = 'cat'
var z = {color: 'blue'}
I can log all of them like this:
console.log('The values are:', x, y, z)
In dart, you can import 'dart:html'
and it will map print
to console.log
in the compiled javascript. But print
only takes one parameter - not 3. This dart will fail when the compiled js runs in the browser:
print('The values are:', x, y, z)
The only thing I can think to do is stringify these arguments and join them into one string, and print that. But then I lose Chrome's ability to expand objects that are printed to the console.
Is it possible to print multiple objects with one print
statement (or similar statement)? If so, how?
If you simlpy want to print text to the console you can use print('Text') . But if you want to access the advanced fatures of the DevTools console you need to use the Console class from dart:html : Console. log('Text') . It supports printing on different levels (info, warn, error, debug).
you can simply use print('whatever you want to print') same as console. log() in javascript. for more info you can check here. Save this answer.
Print Long String in console While developing flutter app The Right way to log data on console is by importing dart inbuilt package “dart:developer”, This allows a developer to print longs information on console while debugging. So to use developer. log function in flutter app you need to import it.
What about: ?
print('The values are: ${[x, y, z]}')
or
print('The values are: $x, $y, $z')
or
['The values are:', x, y, z].forEach(print);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With