exampleMainSentry function
void
exampleMainSentry()
RECOMMENDED main() — dreamic owns the handlers; main() wraps runApp in the guarded zone and (Path A′) installs the early web-JS handlers.
Implementation
void exampleMainSentry() async {
/*
WidgetsFlutterBinding.ensureInitialized(); // boot step 1
installEarlyErrorHandlers(); // boot step 2
// boot step 3 — Path A′ ONLY (gated by the consumer's kWebDartCapture):
// install the Dart window 'error'/'unhandledrejection' listeners as the sole
// web capture surface. Omit under Path C. No-op on mobile.
if (kWebDartCapture) {
DreamicErrorHandling.installEarlyWebErrorHandlers();
}
// boot step 4 — register the reporter. managesOwnErrorHandlers: false (dreamic
// installs the handlers); requiresFirebase: false (Sentry attaches BEFORE
// Firebase for maximal startup coverage, incl. web).
configureErrorReporting(
ErrorReportingConfig.customOnly(
reporter: SentryErrorReporter(dsn: AppConfig.sentryDsn),
enableOnWeb: true,
),
);
// boot step 5 — the lifelong, outermost guarded zone. onError defaults to
// DreamicErrorHandling.recordZoneError, so this is all that's needed.
DreamicErrorHandling.runGuarded(() {
runApp(DreamicAppInitHost(
initFutureFactory: () => dreamicBootstrap(/* firebaseOptions, hooks, ... */),
splash: const DreamicSplash(),
child: const MyApp(),
));
});
// dreamicBootstrap() runs appInitErrorHandling() behind the splash: it calls
// initialize() (initializing Sentry), attaches the reporter, registers the
// isolate listener, and flushes the early buffers (breadcrumbs-then-errors).
*/
}