kiwi-bop / flutter_crashlytics

:package: Flutter plugin for Crashlytics integration
BSD 2-Clause "Simplified" License
194 stars 46 forks source link

The error is not print to console in debug mode. #76

Open PandaGeek1024 opened 5 years ago

PandaGeek1024 commented 5 years ago

I'm developing an iOS app and I followed the example to setup everything and it does send logs to firebase console. But when I set isInDebugMode to true, somehow it just doesn't print it to android studio log. Am I doing something wrong?

Future<void> main() async {

  bool isInDebugMode = true;

  FlutterError.onError = (FlutterErrorDetails details) {
    if (isInDebugMode) {
      // In development mode simply print to console.
      FlutterError.dumpErrorToConsole(details);
    } else {
      // In production mode report to the application zone to report to
      // Crashlytics.
      Zone.current.handleUncaughtError(details.exception, details.stack);
    }
  };

  await FlutterCrashlytics().initialize();

  runZoned<Future<Null>>(() async {
    await Firestore().settings(timestampsInSnapshotsEnabled: true);
    runApp(MaterialApp(
        builder: (buildContext, child) {
          return AppStateProvider.wrap(child);
        },
        home: SplashPage()));
  }, onError: (error, stackTrace) async {
    // Whenever an error occurs, call the `reportCrash` function. This will send
    // Dart errors to our dev console or Crashlytics depending on the environment.
    await FlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
  });
}
jaumard commented 5 years ago

FlutterError.dumpErrorToConsole should dump your error on the console, if it doesn't, the issue come from flutter I'll say and not this plugin. Use breakpoint to see if FlutterError.dumpErrorToConsole is called or not

stargazing-dino commented 5 years ago

@PandaGeek1024 I had a similar issue in VSCode. Using the IDE's built-in debugger, my onError was never called. Setting it to null (which should've ignored all errors as stated in these docs) had no effect either.

Running through a terminal with flutter run finally hit the correct handlers and sent the error to the console.