Not getting any error output in Flutter web

Viewed 2081

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.

3 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"]);
}

Did you look to see if it was a known issue? Flutter-web is only at developer preview level. If there's not a current issue, create one, and provide a minimal "how to reproduce". I'm sure the Flutter-web team would appreciate it.

I tried in both IDE and its correctly working in Intellij but not in VSCode. Its showing white blank screen give it try to run again flutter run -d chrome and wait in blank screen for 2minutes.

And check the SDK path of flutter in visual code is correct or not.

Related