← Back to Pull requests

Fix: FlutterError on Snackbar Overlay #547

Closed
SantamRC closed this pull request without merging on Jun 07, 2026 14:18 UTC
View on GitHub
SantamRC SantamRC commented on Mar 23, 2026 13:01 UTC
Author

Fixes #

This fixes the FlutterError on Snackbar Overlay issue #545

Login issue: the snackbar was trying to show before the app's overlay (the layer that displays floating UI like snackbars) was fully ready. Fixed by wrapping the call in a Future.microtask so it waits for the overlay to be mounted.

Logout issue: the snackbar was trying to show after the overlay was already destroyed. When logout fires, it clears the user session and triggers a navigation change that tears down the overlay — and GetX's snackbar queue runs too late, finding nothing to attach to. Fixed by capturing the ScaffoldMessengerState before logout starts, since it lives higher in the widget tree and survives navigation changes.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

Release Notes

New Features
Logout operations now provide immediate user feedback with a localized confirmation message.

Bug Fixes
Optimized login form validation flow with improved error handling and messaging.
* Enhanced notification styling and context-aware display for better user experience.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 178 lines (+144 / -34) across 4 files Reviewer: magic-peach Review duration: 109516m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.43) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 178 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.72 · 5 substantive comment(s)
0.72
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.310
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
12 items
netlify[bot] netlify[bot] commented on Mar 23, 2026 13:01 UTC
Bot

<span aria-hidden="true">✅</span> Deploy Preview for cv-mobile-app-web ready!

| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 765f97f4356e7fb9d2b7f3f8d72636e31de5b0a6 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/cv-mobile-app-web/deploys/69c139b08909250008916999 |
|<span aria-hidden="true">😎</span> Deploy Preview | https://deploy-preview-547--cv-mobile-app-web.netlify.app |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />!QR Code<br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- cv-mobile-app-web Preview -->
_To edit notification comments on pull requests, go to your Netlify project configuration._

coderabbitai[bot] coderabbitai[bot] commented on Mar 23, 2026 13:01 UTC
Bot

<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

Walkthrough

This change refactors the logout and snackbar handling across multiple files. The onLogoutPressed() method in the viewmodel now returns Future<bool> instead of Future<void> to indicate logout confirmation status, and no longer triggers snackbar display. The UI layer (cv_drawer.dart and login_view.dart) now handles snackbar notifications conditionally based on the returned boolean. Additionally, snackbar_utils.dart introduces a new showDarkWithContext() method using ScaffoldMessenger for context-aware snackbar display and consolidates snackbar creation logic into a private helper method. The dark snackbar background opacity is also adjusted from 0.8 to 0.85.

<!-- walkthrough_end -->

<!-- pre_merge_checks_walkthrough_start -->

<details>
<summary>🚥 Pre-merge checks | ✅ 3</summary>

<details>
<summary>✅ Passed checks (3 passed)</summary>

| Check name | Status | Explanation |
| :----------------: | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Fix: FlutterError on Snackbar Overlay' directly addresses the main issue being fixed—a FlutterError related to snackbar overlay timing. It clearly identifies the problem area and the type of fix being applied. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |

</details>

<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>

</details>

<!-- pre_merge_checks_walkthrough_end -->

<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

<details>
<summary>🧪 Generate unit tests (beta)</summary>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
  • </details>

    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- tips_start -->

    ---

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>

    <sub>Comment @coderabbitai help to get the list of available commands and usage tips.</sub>

    <!-- tips_end -->

    <!-- internal state start -->

    <!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAYvAAevh54NBQAohQU+Hz4WADKGGgMANYCzpAA8lIUHmjykAYAco4ClFwArAAsAOyQBQCqNgAyXLC4uNyIHAD03UTqsNgCGkzM3QDC8BQM2OoAapSIJN3MgvBeYGjc3N3c2B4e3VW1DUsUXHGYuGjMNuN1BnH42NMkkAJUGAywXIiJKWkKGBKFE+IAkwhgzlIuHen2+XGYaEQoQecWuuGwXX43DIDxsJAk8BIAHdFlxxvhuOt8DCCuMKCRqHR0JxIAAmAAMbIAbGAOQBmMBs/nQACM/I4HNFHH5/IAWm4EMg9gdIAyAI7YaQwtC0WgMxBLZC4WBvHzBdqUCKg/jxf6pdJZSi5eRIBxvAAUZiq5QAlBoYMT8JBaEhxF8YX8kg6+OJmPAMEQeFEBF5mMhnG8AGYBOgcIxQJr4fpYN1ai72wHIUkMlk0ZjccNJgj2WD4YnvEhZ6JvE1vLbcADkyHw2RdkA9fcgLsokBN1BDSG4LuQWY8+GoCaT9QAktP4Mk3lGAc5EL7IMSkZAs/s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ar 23, 2026 13:05 UTC
    Code Review
    lib/viewmodels/cv_landing_viewmodel.dart:1
    @@ -80,23 +80,22 @@ class CVLandingViewModel extends BaseModel {
         }
       }
     
    -  Future<void> onLogoutPressed() async {
    +  Future<bool> onLogoutPressed() async {
         Get.back();
     
    -    var _dialogResponse = await _dialogService.showConfirmationDialog(
    +    var response = await _dialogService.showConfirmationDialog(

    SnackBarUtils is no longer used in this viewmodel (the logout success snackbar was removed), so the snackbar_utils.dart import at the top of the file should be removed to avoid an unused_import lint/analyzer warning.

    Copilot Copilot commented on code on Mar 23, 2026 13:05 UTC
    Code Review
    lib/viewmodels/cv_landing_viewmodel.dart:1
    @@ -80,23 +80,22 @@ class CVLandingViewModel extends BaseModel {
         }
       }
     
    -  Future<void> onLogoutPressed() async {
    +  Future<bool> onLogoutPressed() async {
         Get.back();
     
    -    var _dialogResponse = await _dialogService.showConfirmationDialog(
    +    var response = await _dialogService.showConfirmationDialog(
           title: AppLocalizations.of(Get.context!)!.cv_logout,
           description: AppLocalizations.of(Get.context!)!.cv_logout_confirmation,
           confirmationTitle:
               AppLocalizations.of(Get.context!)!.cv_logout_confirmation_button,
         );
     
    -    if (_dialogResponse?.confirmed ?? false) {
    +    if (response?.confirmed ?? false) {
           onLogout();
           selectedIndex = 0;
    -      SnackBarUtils.showDark(
    -        AppLocalizations.of(Get.context!)!.cv_logout_success,
    -        AppLocalizations.of(Get.context!)!.cv_logout_success_acknowledgement,
    -      );
    +      return true; 

    onLogout() is an async function but returns void, so it can't be awaited here. As a result, onLogoutPressed() returns true (and the UI can show a “logout success” snackbar) before Google sign-out/session clearing has actually finished. Consider changing onLogout() to return Future<void> and awaiting it here before returning true (and handle/signals errors if sign-out fails).

    Copilot Copilot commented on code on Mar 23, 2026 13:05 UTC
    Code Review
    lib/utils/snackbar_utils.dart:1
    @@ -3,16 +3,85 @@ import 'package:get/get.dart';
     
     class SnackBarUtils {
       static void showLight(String title, String message) {
    -    Get.snackbar(title, message, snackPosition: SnackPosition.BOTTOM);
    +    _show(
    +      title: title,
    +      message: message,
    +      backgroundColor: Colors.white,
    +      textColor: Colors.black,
    +    );
       }
     
       static void showDark(String title, String message) {
    -    Get.snackbar(
    -      title,
    -      message,
    -      snackPosition: SnackPosition.BOTTOM,
    -      backgroundColor: Colors.black.withValues(alpha: 0.8),
    -      colorText: Colors.white,
    +    _show(
    +      title: title,
    +      message: message,
    +      backgroundColor: Colors.black.withValues(alpha: 0.85),
    +      textColor: Colors.white,
    +    );
    +  }
    +
    +  static void showDarkWithContext(
    +    BuildContext context,
    +    String title,
    +    String message,
    +  ) {
    +    ScaffoldMessenger.of(context).showSnackBar(
    +      SnackBar(
    +        content: Column(
    +          mainAxisSize: MainAxisSize.min,
    +          crossAxisAlignment: CrossAxisAlignment.start,
    +          children: [
    +            Text(
    +              title,
    +              style: const TextStyle(
    +                color: Colors.white,
    +                fontWeight: FontWeight.bold,
    +              ),
    +            ),
    +            Text(message, style: const TextStyle(color: Colors.white)),
    +          ],
    +        ),
    +        backgroundColor: Colors.black.withValues(alpha: 0.85),
    +        behavior: SnackBarBehavior.floating,
    +        margin: const EdgeInsets.all(12),
    +        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
    +        duration: const Duration(seconds: 2),
    +      ),
         );
       }
    -}
    +
    +  static void _show({
    +    required String title,
    +    required String message,
    +    required Color backgroundColor,
    +    required Color textColor,
    +  }) {
    +    if (Get.context == null) return;
    +
    +    if (Get.isSnackbarOpen) {
    +      Get.closeCurrentSnackbar();
    +    }
    +
    +    Future.microtask(() {

    The Get.context == null guard happens before scheduling the microtask, but Get.rawSnackbar() runs later and can still throw if the overlay/context becomes unavailable in the meantime (the race this PR is addressing). To make this robust, re-check the required context/overlay inside the scheduled callback and/or use a post-frame callback (WidgetsBinding.instance.addPostFrameCallback) instead of Future.microtask so it runs after the next build when the overlay is mounted.

        WidgetsBinding.instance.addPostFrameCallback((_) {
          if (Get.context == null) {
            return;
          }
    
          if (Get.isSnackbarOpen) {
            Get.closeCurrentSnackbar();
          }
    

    Copilot Copilot commented on code on Mar 23, 2026 13:05 UTC
    Code Review
    lib/ui/components/cv_drawer.dart:1
    @@ -220,7 +220,37 @@ class CVDrawer extends StatelessWidget {
                             ),
                           ),
                           InkWell(
    -                        onTap: _model.onLogoutPressed,
    +                        onTap: () async {
    +                          final messenger = ScaffoldMessenger.of(context);
    +                          final logoutSuccess = AppLocalizations.of(context)!.cv_logout_success;
    +                          final logoutAck = AppLocalizations.of(context)!.cv_logout_success_acknowledgement;
    +                          final confirmed = await _model.onLogoutPressed();
    +                          if (confirmed) {
    +                            messenger.showSnackBar(
    +                              SnackBar(
    +                                content: Column(
    +                                  mainAxisSize: MainAxisSize.min,
    +                                  crossAxisAlignment: CrossAxisAlignment.start,
    +                                  children: [
    +                                    Text(
    +                                      logoutSuccess,
    +                                      style: const TextStyle(
    +                                        color: Colors.white,
    +                                        fontWeight: FontWeight.bold,
    +                                      ),
    +                                    ),
    +                                    Text(logoutAck, style: const TextStyle(color: Colors.white)),
    +                                  ],
    +                                ),
    +                                backgroundColor: Colors.black.withValues(alpha: 0.85),
    +                                behavior: SnackBarBehavior.floating,
    +                                margin: const EdgeInsets.all(12),
    +                                shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
    +                                duration: const Duration(seconds: 2),
    +                              ),
    +                            );

    This logout snackbar duplicates styling/markup that now also exists in SnackBarUtils (and is likely to be needed elsewhere). Consider centralizing this (e.g., add a SnackBarUtils.showDarkWithMessenger(ScaffoldMessengerState, ...) or similar) so the app has one consistent snackbar implementation and future style tweaks don't require editing multiple widgets.

                              final logoutSuccess = AppLocalizations.of(context)!.cv_logout_success;
                              final logoutAck = AppLocalizations.of(context)!.cv_logout_success_acknowledgement;
                              final confirmed = await _model.onLogoutPressed();
                              if (confirmed) {
                                SnackBarUtils.showDark(context, logoutSuccess, logoutAck);
    

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Mar 23, 2026 13:05 UTC
    Reviewer

    Pull request overview

    This PR addresses the “No Overlay widget found” FlutterError occurring during authentication flows by changing when/how snackbars are shown so they aren’t triggered while the overlay is not yet available (login) or after it has been torn down (logout).

    Changes:

  • Refactors SnackBarUtils to use a shared internal _show() that defers snackbar display via scheduling.

  • Updates login flow to navigate first and then show the success snackbar shortly after.

  • Moves logout success snackbar display out of the viewmodel and into the drawer UI, using ScaffoldMessengerState captured before logout actions.
  • Reviewed changes

    Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

    | File | Description |
    | ---- | ----------- |
    | lib/viewmodels/cv_landing_viewmodel.dart | Changes logout handler to return a bool for confirmation and removes snackbar side-effect from the viewmodel. |
    | lib/utils/snackbar_utils.dart | Reworks snackbar implementation to a centralized helper and adds a ScaffoldMessenger-based variant. |
    | lib/ui/views/authentication/login_view.dart | Adjusts login success flow to navigate before showing snackbar to avoid overlay timing issues. |
    | lib/ui/components/cv_drawer.dart | Shows logout success snackbar via ScaffoldMessenger captured before logout-triggered navigation changes. |

    ---

    💡 <a href="/CircuitVerse/mobile-app/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

    coderabbitai[bot] coderabbitai[bot] commented on code on Mar 23, 2026 13:14 UTC
    Code Review
    lib/ui/views/authentication/login_view.dart:1
    @@ -128,24 +128,36 @@ class _LoginViewState extends State<LoginView> {
       }
     
       Future<void> _validateAndSubmit() async {
    -    if (Validators.validateAndSaveForm(_formKey) &&
    -        !_model.isBusy(_model.LOGIN)) {
    -      FocusScope.of(context).requestFocus(FocusNode());
    -      await _model.login(_email, _password);
    -      if (_model.isSuccess(_model.LOGIN)) {
    -        SnackBarUtils.showDark(
    -          AppLocalizations.of(context)!.login_success_title,
    -          AppLocalizations.of(context)!.login_success_message,
    -        );
    -        await Future.delayed(const Duration(seconds: 1));
    -        await Get.offAllNamed(CVLandingView.id);
    -      } else if (_model.isError(_model.LOGIN)) {
    -        SnackBarUtils.showDark(
    -          AppLocalizations.of(context)!.login_error,
    -          _model.errorMessageFor(_model.LOGIN),
    -        );
    -        _formKey.currentState?.reset();
    -      }
    +    if (!Validators.validateAndSaveForm(_formKey) ||
    +        _model.isBusy(_model.LOGIN)) {
    +      return;
    +    }
    +
    +    // Dismiss keyboard
    +    FocusScope.of(context).unfocus();
    +
    +    await _model.login(_email, _password);
    +
    +    // Capture strings BEFORE any async navigation (important)
    +    final successTitle = AppLocalizations.of(context)!.login_success_title;
    +    final successMessage = AppLocalizations.of(context)!.login_success_message;
    +
    +    final errorTitle = AppLocalizations.of(context)!.login_error;

    _⚠️ Potential issue_ | _🟠 Major_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    # First, let's locate and examine the login_view.dart file
    fd "login_view.dart" --type f
    

    Repository: CircuitVerse/mobile-app

    Length of output: 110

    ---

    🏁 Script executed:

    # Get the content of the login view to understand the full context
    cat -n lib/ui/views/authentication/login_view.dart | head -200
    

    Repository: CircuitVerse/mobile-app

    Length of output: 7786

    ---

    🏁 Script executed:

    # Search for the mounted pattern usage in the codebase to see if this is a common practice
    rg "if \(!mounted\)" --type dart -B 2 -A 2 | head -50
    

    Repository: CircuitVerse/mobile-app

    Length of output: 49

    ---

    🏁 Script executed:

    # Check what class LoginView extends
    ast-grep --pattern 'class LoginView $$$'
    

    Repository: CircuitVerse/mobile-app

    Length of output: 49

    ---

    </details>

    Add a mounted guard after the login await.

    After await _model.login(...) completes, the widget could be disposed if the user navigates away during the request. This makes the subsequent AppLocalizations.of(context) calls unsafe—the context becomes stale and the inherited-widget lookup can fail or crash.

    <details>
    <summary>Suggested fix</summary>

         await _model.login(_email, _password);
    +    if (!mounted) return;
     
         // Capture strings BEFORE any async navigation (important)
    

    </details>

    <!-- fingerprinting:phantom:medusa:grasshopper -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Mar 23, 2026 13:14 UTC
    Code Review
    lib/viewmodels/cv_landing_viewmodel.dart:1
    @@ -80,23 +80,22 @@ class CVLandingViewModel extends BaseModel {
         }
       }
     
    -  Future<void> onLogoutPressed() async {
    +  Future<bool> onLogoutPressed() async {
         Get.back();
     
    -    var _dialogResponse = await _dialogService.showConfirmationDialog(
    +    var response = await _dialogService.showConfirmationDialog(
           title: AppLocalizations.of(Get.context!)!.cv_logout,
           description: AppLocalizations.of(Get.context!)!.cv_logout_confirmation,
           confirmationTitle:
               AppLocalizations.of(Get.context!)!.cv_logout_confirmation_button,
         );
     
    -    if (_dialogResponse?.confirmed ?? false) {
    +    if (response?.confirmed ?? false) {
           onLogout();
           selectedIndex = 0;
    -      SnackBarUtils.showDark(
    -        AppLocalizations.of(Get.context!)!.cv_logout_success,
    -        AppLocalizations.of(Get.context!)!.cv_logout_success_acknowledgement,
    -      );
    +      return true; 

    _⚠️ Potential issue_ | _🟠 Major_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    # First, let me locate and examine the cv_landing_viewmodel.dart file
    cd /tmp && git ls-files | grep -i "cv_landing_viewmodel"
    

    Repository: CircuitVerse/mobile-app

    Length of output: 135

    ---

    🏁 Script executed:

    # Examine the onLogoutPressed and onLogout methods
    cat -n lib/viewmodels/cv_landing_viewmodel.dart | sed -n '40,100p'
    

    Repository: CircuitVerse/mobile-app

    Length of output: 1935

    ---

    🏁 Script executed:

    # Check how onLogoutPressed is used in cv_drawer.dart
    fd "cv_drawer" --type f
    

    Repository: CircuitVerse/mobile-app

    Length of output: 137

    ---

    🏁 Script executed:

    # Examine how onLogoutPressed is used in cv_drawer.dart
    cat -n lib/ui/components/cv_drawer.dart | grep -A 5 -B 5 "onLogoutPressed"
    

    Repository: CircuitVerse/mobile-app

    Length of output: 1456

    ---

    🏁 Script executed:

    # Let me also check the full context around the logout snackbar to confirm the usage
    cat -n lib/ui/components/cv_drawer.dart | sed -n '220,240p'
    

    Repository: CircuitVerse/mobile-app

    Length of output: 1399

    ---

    </details>

    Await logout completion before returning success.

    onLogoutPressed() gates the logout-success snackbar, but onLogout() is async void, so it returns immediately before GoogleSignIn.signOut() completes. If signout fails, the exception is swallowed and the method still returns true, causing the caller to show a success message even though logout failed.

    Change onLogout() to return Future<void> and await it before resetting state and returning:

    <details>
    <summary>Suggested fix</summary>

    -  void onLogout() async {
    +  Future<void> onLogout() async {
         _storage.isLoggedIn = false;
         _storage.currentUser = null;
         _storage.token = null;
    @@
    -      onLogout();
    +      await onLogout();
           selectedIndex = 0;
           return true;
    

    </details>

    <!-- fingerprinting:phantom:medusa:grasshopper -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    coderabbitai[bot] coderabbitai[bot] requested changes on Mar 23, 2026 13:14 UTC
    Changes Requested Reviewer

    Actionable comments posted: 2

    <details>
    <summary>🧹 Nitpick comments (1)</summary><blockquote>

    <details>
    <summary>lib/utils/snackbar_utils.dart (1)</summary><blockquote>

    23-51: Take a captured ScaffoldMessengerState here instead of BuildContext.

    The safe value across drawer dismissal is the messenger, not the drawer context. That’s why lib/ui/components/cv_drawer.dart still has to inline the same SnackBar body instead of reusing this helper.

    <details>
    <summary>Suggested API shape</summary>

    -  static void showDarkWithContext(
    -    BuildContext context,
    +  static void showDarkWithMessenger(
    +    ScaffoldMessengerState messenger,
         String title,
         String message,
       ) {
    -    ScaffoldMessenger.of(context).showSnackBar(
    +    messenger.showSnackBar(
           SnackBar(
    

    </details>

    </blockquote></details>

    </blockquote></details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: Organization UI

    Review profile: CHILL

    Plan: Pro

    Run ID: 2a5d5ae4-377c-4273-9013-b0324ac99cd6

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between f621531ff51327b83f37459c942eaea036e352d6 and 765f97f4356e7fb9d2b7f3f8d72636e31de5b0a6.

    </details>

    <details>
    <summary>📒 Files selected for processing (4)</summary>

    lib/ui/components/cv_drawer.dart
    lib/ui/views/authentication/login_view.dart
    lib/utils/snackbar_utils.dart
    lib/viewmodels/cv_landing_viewmodel.dart

    </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    magic-peach magic-peach approved these changes on May 25, 2026 04:33 UTC
    Approved Reviewer

    Correct approach throughout. Capturing ScaffoldMessenger.of(context) and the localization strings before the await prevents the context-not-mounted crash, and building the snackbar inline gives full control over the timing. The Future.microtask wrapper on the login side defers snackbar rendering until the overlay is mounted.

    Reviewers
    Assignees
    SantamRC SantamRC
    Labels
    risk: low confidence: 83.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.4% (MEDIUM) · Higher = larger blast radius
    43.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.9% · Lower = rushed or shallow review
    83.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.0% · Safe to merge
    7.0%