I'm using Flutter 1.10.15
and Android Studio 3.5.1
for Flutter Web development and my big! problem is I can't debug and even I can't print something in console because only a white page is displayed in chrome
when I press "run" or "debug" button in toolbar.
The only way I can run project is in web-server mode with following command and showing variable values and exceptions in AlertDialog
popup!:
flutter run -d web-server --web-hostname=192.168.50.147 --web-port=5624 --local-engine=host_debug_unopt --profile -v lib\pages\splash.dart
Can anyone tell me a solution?
You can use print() or debugPrint() for logging. print() may truncate some logs in android if it is too much. use debugPrint() or debugPrintThrottled() to avoid this. log also helps in dart dev tools to show formatted logging.
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.
import 'dart:developer'; log('data: $data'); You can also use print() , but this is not a good practice because it can slow down your program in a production environment. debugPrint , log and other methods will prevent this. Save this answer.
I could finally find that Google Chrome DevTools
feature has a "Console" section that shows all prints written in Flutter Web
's dart code when running project in Web-Server
mode.
This is while in Web-Server
mode, non of prints are shown in Android Studio console.
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