Skip to content

"RenderBox was not laid out" Error When Navigating with ShowcaseView Overlay in Flutter #172293

@shubhrajyotidey305

Description

@shubhrajyotidey305

Steps to reproduce

Summary

After upgrading Flutter from v3.24.3 to v3.32.6, navigation that replaces the widget tree (e.g., logout) causes a persistent assertion error related to overlays created by the showcaseview package. This issue did not occur on earlier Flutter versions, and all recommended lifecycle and overlay cleanup steps have been attempted without success.

Environment

  • Flutter Version: 3.32.6
  • ShowcaseView Version: ^4.0.1
  • Platform: Android/iOS (reproduced on both)
  • Navigation: In-app navigator with navigatorKey.currentState!.pushNamedAndRemoveUntil('/', (Route route) => false);

Error Details

════════ Exception caught by widgets library ═══════════════════════════════════
RenderBox was not laid out: RenderFractionalTranslation#a56d8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2251 pos 12: 'hasSize'
The relevant error-causing widget was:
    Navigator Navigator ...
#2      RenderBox.size (package:flutter/src/rendering/box.dart:2251:12)
#3      RenderFractionalTranslation.applyPaintTransform (package:flutter/src/rendering/proxy_box.dart:3081:42)
...

Steps to Reproduce

  1. Setup

    • Main screen contains a widget tree wrapped in ShowCaseWidget.
    • Guided highlights are started conditionally after build, using keys (e.g., _plusIconShowcaseKey, _dropDownShowcaseKey).
    • Navigation is handled with a custom navigatorKey.
  2. Logout Flow

    • Triggers data clearing and abrupt route replacement with pushNamedAndRemoveUntil.
    • No new showcase is started, but overlays may have been recently active.
  3. Result

    • During navigation away from the dashboard, Flutter throws a RenderBox was not laid out assertion.
    • Error surfaces in the stack trace related to Showcase overlay layout (RenderFractionalTranslation).

Attempts to Fix

  • Explicitly called ShowCaseWidget.of(context).dismiss() before navigation.
  • Ensured no ShowCaseWidget.of(context).startShowCase() is triggered during logout (confirmed via breakpoints).
  • Popped all modal sheets/dialogs before navigating away.
  • Deferred navigation using WidgetsBinding.instance.addPostFrameCallback.
  • Checked and guarded for active overlays or delayed async callbacks.
  • Updated showcase package to the latest version.
  • Validated that modal/overlay targets are not unmounted or unlaid out by the time navigation occurs.

None of these steps resolved the issue on Flutter 3.32.6. The error persists consistently every time navigation clears the stack while Showcase overlay was (potentially) used.

Additional Context

  • This problem did not exist in Flutter 3.24.3 with the same code and package version.
  • It appears after the upgrade, possibly due to stricter layout assertions or overlay lifecycle management changes in Flutter.
  • Showcase overlays are not active when logout is triggered, but the widget tree has previously used them in the same session.

Request

  • Clarification on changes in the Flutter rendering pipeline or overlay system that could cause this regression.
  • Guidance for package maintainers on adapting ShowcaseView to avoid overlay layout issues with the new Flutter versions.
  • Any workaround or systematic fix to prevent overlays (from Showcase or similar packages) from triggering assertion failures during widget tree teardown or navigation replacement?

Attachments

  • Stack trace (as above)
  • Brief setup and reproduction code snippets (see above)

Thank you! Please advise on resolving or mitigating this regression for apps using ShowcaseView and abrupt navigation on recent Flutter versions.

Expected results

Expected Behavior

  • Navigating away or logging out should not trigger overlay or render assertion errors, even if Showcase was previously used or overlays were recently active.

Actual results

Actual Behavior

  • Upon navigation, an exception is thrown (RenderBox was not laid out), and the app's stability is compromised. App did not experience this problem before upgrading Flutter.

Code sample

Sample Logout Function

Future logoutAndClearData(BuildContext context) async {
  // ...data clearing and preference removal...
  final showCase = ShowCaseWidget.of(context);
  if (showCase != null && showCase.isShowCaseActive) {
    showCase.dismiss();
  }
  while (Navigator.of(context).canPop()) {
    Navigator.of(context).pop();
  }
  WidgetsBinding.instance.addPostFrameCallback((_) {
    navigatorKey.currentState!
        .pushNamedAndRemoveUntil('/', (Route route) => false);
  });
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions