@@ -564,6 +564,51 @@ void main() {
564564 }
565565 });
566566
567+ testWidgets ('addBreadcrumb and clearBreadcrumbs sync to native' ,
568+ (tester) async {
569+ await restoreFlutterOnErrorAfter (() async {
570+ await setupSentryAndApp (tester);
571+ });
572+
573+ // 1. Add a breadcrumb via Dart
574+ final testBreadcrumb = Breadcrumb (
575+ message: 'test-breadcrumb-message' ,
576+ category: 'test-category' ,
577+ level: SentryLevel .info,
578+ );
579+ await Sentry .addBreadcrumb (testBreadcrumb);
580+
581+ // 2. Verify it appears in native via loadContexts
582+ var contexts = await SentryFlutter .native ? .loadContexts ();
583+ expect (contexts, isNotNull);
584+
585+ var breadcrumbs = contexts! ['breadcrumbs' ] as List <dynamic >? ;
586+ expect (breadcrumbs, isNotNull,
587+ reason: 'Breadcrumbs should not be null after adding' );
588+ expect (breadcrumbs! .isNotEmpty, isTrue,
589+ reason: 'Breadcrumbs should not be empty after adding' );
590+
591+ // Find our test breadcrumb
592+ final testCrumb = breadcrumbs.firstWhere (
593+ (b) => b['message' ] == 'test-breadcrumb-message' ,
594+ orElse: () => null ,
595+ );
596+ expect (testCrumb, isNotNull,
597+ reason: 'Test breadcrumb should exist in native breadcrumbs' );
598+ expect (testCrumb['category' ], equals ('test-category' ));
599+
600+ // 3. Clear breadcrumbs
601+ await Sentry .configureScope ((scope) async {
602+ await scope.clearBreadcrumbs ();
603+ });
604+
605+ // 4. Verify they're cleared in native
606+ contexts = await SentryFlutter .native ? .loadContexts ();
607+ breadcrumbs = contexts! ['breadcrumbs' ] as List <dynamic >? ;
608+ expect (breadcrumbs == null || breadcrumbs! .isEmpty, isTrue,
609+ reason: 'Breadcrumbs should be null or empty after clearing' );
610+ });
611+
567612 testWidgets ('loads debug images through loadDebugImages' , (tester) async {
568613 await restoreFlutterOnErrorAfter (() async {
569614 await setupSentryAndApp (tester);
0 commit comments