Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not getting any error output in Flutter web

I'm unable to get any error output from my Flutter web app. Printing to the console using

print('some text');

works fine, but no errors get printed. For example, throwing an exception

throw new Exception('testexception');

doesn't result in any output, neither in the browser console nor in IntelliJ. The log level settings in Chrome are set to [Info, Warnings, Errors].

I even tried implementing a custom error handler

void main(){
    FlutterError.onError = (FlutterErrorDetails details) {
        print('main.onError: details: ${details.toString()}');
    };

    runApp(new MyApp());
}

but no luck. Do I have to enable error outputs somewhere? I can't find any info about this in the documentation.

I tried running the app both using the Dart Dev Server (which is started when using Run from IntelliJ), as well as calling webdev serve and webdev serve --auto restart from the Terminal.

like image 696
Magnus Avatar asked Nov 14 '25 19:11

Magnus


1 Answers

Flutter Web currently doesn't have a way to be debugged. Will generate a main.dart.js and you can debug it with Chrome console.

One cool trick to "debug" your Web App, is by showing a popup to your browser:

import 'dart:js' as js;

@override
void initState() {
  super.initState();

  js.context.callMethod("alert", <String>["Your debug message"]);
}
like image 122
Mariano Zorrilla Avatar answered Nov 17 '25 07:11

Mariano Zorrilla