Skip to content

Commit

Permalink
Fix firebase crashlytics record error
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Sep 10, 2020
1 parent b531341 commit 1c7ece1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:io';
import 'package:ap_common/utils/preferences.dart';
import 'package:ap_common_firebase/utils/firebase_utils.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:nsysu_ap/config/constants.dart';

Expand All @@ -21,7 +20,11 @@ void main() async {
await Firebase.initializeApp();
if (FirebaseUtils.isSupportCrashlytics) {
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
}
runApp(MyApp());
runZonedGuarded(() {
runApp(MyApp());
}, (error, stackTrace) {
FirebaseCrashlytics.instance.recordError(error, stackTrace);
});
} else
runApp(MyApp());
}

0 comments on commit 1c7ece1

Please sign in to comment.