mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Co-authored-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1ft62tztwwm2x9xamk25smmuaj4sfckdkldksruf2x2jwqalffkrq0g7arr <4af4a5896e76d4629bbbb2a90def9d95609c59b6fb6d01f12a32a4e077e94d86@sprout-oss.stage.blox.sqprod.co>
51 lines
1.5 KiB
Dart
51 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'app.dart';
|
|
import 'shared/diagnostics/diagnostics.dart';
|
|
import 'shared/theme/theme_provider.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Pre-load preferences so startup can apply saved diagnostics consent and
|
|
// the first frame uses the saved theme/accent.
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final diagnosticsController = DiagnosticsController(
|
|
preferences: prefs,
|
|
config: const SentryConfig.fromEnvironment(),
|
|
crashReporter: const SentryCrashReporter(),
|
|
);
|
|
await applyStartupDiagnosticsConsent(diagnosticsController);
|
|
|
|
runApp(
|
|
ProviderScope(
|
|
overrides: [
|
|
savedPrefsProvider.overrideWithValue(prefs),
|
|
diagnosticsControllerProvider.overrideWith(
|
|
(_) => diagnosticsController,
|
|
),
|
|
],
|
|
child: const App(),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Applies diagnostics consent without allowing optional crash reporting to
|
|
/// prevent the app from starting.
|
|
@visibleForTesting
|
|
Future<void> applyStartupDiagnosticsConsent(
|
|
DiagnosticsController diagnosticsController, {
|
|
DiagnosticsLog? log,
|
|
}) async {
|
|
try {
|
|
await diagnosticsController.applyStartupConsent();
|
|
} on Object catch (error, stackTrace) {
|
|
(log ?? debugPrint)(
|
|
'Diagnostics startup failed; continuing without crash reporting: '
|
|
'$error\n$stackTrace',
|
|
);
|
|
}
|
|
}
|