fix: fix zone assertion error.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -10,11 +10,6 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||||||
import 'firebase_options.dart';
|
import 'firebase_options.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
await Firebase.initializeApp(
|
|
||||||
options: DefaultFirebaseOptions.currentPlatform,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Captures errors reported by the Flutter framework.
|
/// Captures errors reported by the Flutter framework.
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
@@ -26,6 +21,8 @@ Future<void> main() async {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Captures errors reported by the native environment, including native iOS
|
||||||
|
/// and Android code.
|
||||||
Future<void> reportError(dynamic error, StackTrace stackTrace) async {
|
Future<void> reportError(dynamic error, StackTrace stackTrace) async {
|
||||||
// Print the exception to the console.
|
// Print the exception to the console.
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
@@ -38,11 +35,18 @@ Future<void> main() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runs the app wrapped in a [Zone] that captures errors and sends them to
|
||||||
|
/// sentry.
|
||||||
runZonedGuarded(
|
runZonedGuarded(
|
||||||
() async {
|
() async {
|
||||||
await SentryFlutter.init(
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
(options) => options.dsn = sentryDsn,
|
|
||||||
);
|
// Wait for Sentry and Firebase to initialize before running the app.
|
||||||
|
await Future.wait([
|
||||||
|
SentryFlutter.init((options) => options.dsn = sentryDsn),
|
||||||
|
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform),
|
||||||
|
]);
|
||||||
|
|
||||||
runApp(const StreamChatSampleApp());
|
runApp(const StreamChatSampleApp());
|
||||||
},
|
},
|
||||||
reportError,
|
reportError,
|
||||||
|
|||||||
Reference in New Issue
Block a user