Created
August 31, 2022 06:41
-
-
Save mono0926/288a50ccba1109f4d6dd2d7c0cfb0764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
final crashlytics = FirebaseCrashlytics.instance; | |
// いずれも未キャッチ例外なので `fatal: true`(ネイティブのクラッシュと同等の扱い)が適切 | |
// (例外処理であまり想定してないException受け取った時などは `fatal: false` でも良い感) | |
// オリジナルの`FlutterError.presentError`は呼ばずともログは充分そう | |
FlutterError.onError = crashlytics.recordFlutterFatalError; | |
PlatformDispatcher.instance.onError = (error, stack) { | |
crashlytics.recordError( | |
error, | |
stack, | |
fatal: true, | |
); | |
return true; | |
}; | |
// 実際にはMaterialAppなど | |
runApp(const SizedBox()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment